Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

63
LINES

< > BotCompany Repo | #1035397 // test_BStack_v2 (OK)

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (24942L/151K).

1  
scope test_BStack_v2
2  
3  
please include function test_BStack.
4  
5  
/* Goal: Java code with backtracking, like this, to return 4 different values:
6  
7  
  S color = "black" or "white";
8  
  S shape = "circle" or "square";
9  
  return "A " + color + " " + shape;
10  
*/
11  
12  
svoid test_BStack_v2() {
13  
  test_BStack_v2_oneBranch();
14  
  test_BStack_v2_twoBranches();
15  
  test_BStack_v2_undos();
16  
  test_BStack_v2_oneBranch3Options();
17  
  test_BStack_v2_twoBranches3Options();
18  
  test_BStack_v2_noOptions();
19  
}
20  
21  
svoid test_BStack_v2_oneBranch() {
22  
  assertEqualsVerbose(
23  
    ll("Color is black", "Color is white"),
24  
    new BStackComputeAllWithPrintStruct(new BStack_v2, new test_BStack_OneBranch)!);
25  
}
26  
27  
svoid test_BStack_v2_oneBranch3Options() {
28  
  assertEqualsVerbose(
29  
    ll("Color is black", "Color is white", "Color is gray"),
30  
    new BStackComputeAllWithPrintStruct(new BStack_v2, new test_BStack_OneBranch3Options)!);
31  
}
32  
33  
svoid test_BStack_v2_twoBranches() {
34  
  assertEqualsVerbose(
35  
    ll("A black circle", "A black square",
36  
      "A white circle", "A white square"),
37  
    new BStackComputeAllWithPrintStruct(new BStack_v2, new test_BStack_TwoBranches)!);
38  
}
39  
40  
svoid test_BStack_v2_twoBranches3Options() {
41  
  assertEqualsVerbose(
42  
    ll("A black circle", "A black square", "A black triangle",
43  
      "A white circle", "A white square", "A white triangle",
44  
      "A gray circle", "A gray square", "A gray triangle"),
45  
    new BStackComputeAllWithPrintStruct(new BStack_v2, new test_BStack_TwoBranches3Options)!);
46  
}
47  
48  
svoid test_BStack_v2_undos() {
49  
  new LS things; // list that is changed during execution to test the undos
50  
  
51  
  var stack = new BStack_v2<>(new test_BStack_TwoBranchesWithUndos(things));
52  
  for (S color : ll("black", "white"))
53  
    for (S shape : ll("circle", "square")) {
54  
      assertEqualsVerbose("A \*color*/ \*shape*/", stack.nextResultWithPrintStruct(10));
55  
      assertEqualsVerbose(ll(color, shape), things);
56  
      stack = stack.backtrack();
57  
    }
58  
  assertNull(stack);}
59  
60  
svoid test_BStack_v2_noOptions() {
61  
  assertInnerExceptionOfTypeVerbose(BStack_v2.NoOptionsException.class,
62  
    -> new BStackComputeAllWithPrintStruct(new BStack_v2, new test_BStack_NoOptions)!);
63  
}

Author comment

Began life as a copy of #1035387

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1035397
Snippet name: test_BStack_v2 (OK)
Eternal ID of this version: #1035397/6
Text MD5: c710cf4800fc914b81eb8e63983d7ec6
Transpilation MD5: baa653ee17761d0b00bb11d0a3e97f5c
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-05-06 01:26:45
Source code size: 2204 bytes / 63 lines
Pitched / IR pitched: No / No
Views / Downloads: 76 / 153
Version history: 5 change(s)
Referenced in: [show references]