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

63
LINES

< > BotCompany Repo | #1035399 // test_BStack_v3 (OK)

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

Libraryless. Click here for Pure Java version (24992L/152K).

1  
scope test_BStack_v3
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_v3() {
13  
  test_BStack_v3_oneBranch();
14  
  test_BStack_v3_twoBranches();
15  
  test_BStack_v3_undos();
16  
  test_BStack_v3_oneBranch3Options();
17  
  test_BStack_v3_twoBranches3Options();
18  
  test_BStack_v3_noOptions();
19  
}
20  
21  
svoid test_BStack_v3_oneBranch() {
22  
  assertEqualsVerbose(
23  
    ll("Color is black", "Color is white"),
24  
    new BStackComputeAllWithPrintStruct(new BStack_v3, new test_BStack_OneBranch)!);
25  
}
26  
27  
svoid test_BStack_v3_oneBranch3Options() {
28  
  assertEqualsVerbose(
29  
    ll("Color is black", "Color is white", "Color is gray"),
30  
    new BStackComputeAllWithPrintStruct(new BStack_v3, new test_BStack_OneBranch3Options)!);
31  
}
32  
33  
svoid test_BStack_v3_twoBranches() {
34  
  assertEqualsVerbose(
35  
    ll("A black circle", "A black square",
36  
      "A white circle", "A white square"),
37  
    new BStackComputeAllWithPrintStruct(new BStack_v3, new test_BStack_TwoBranches)!);
38  
}
39  
40  
svoid test_BStack_v3_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_v3, new test_BStack_TwoBranches3Options)!);
46  
}
47  
48  
svoid test_BStack_v3_undos() {
49  
  new LS things; // list that is changed during execution to test the undos
50  
  
51  
  var stack = new BStack_v3<>(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_v3_noOptions() {
61  
  assertInnerExceptionOfTypeVerbose(BStack_v3.NoOptionsException.class,
62  
    -> new BStackComputeAllWithPrintStruct(new BStack_v3, new test_BStack_NoOptions)!);
63  
}

Author comment

Began life as a copy of #1035397

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1035399
Snippet name: test_BStack_v3 (OK)
Eternal ID of this version: #1035399/3
Text MD5: 9c63ba0fecbd98d11e67617969be435f
Transpilation MD5: b013b90eb1f6da0c552c2cb19c2da6a3
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-05-08 15:57:46
Source code size: 2204 bytes / 63 lines
Pitched / IR pitched: No / No
Views / Downloads: 59 / 93
Version history: 2 change(s)
Referenced in: [show references]