Libraryless. Click here for Pure Java version (24942L/151K).
scope test_BStack_v2 please include function test_BStack. /* Goal: Java code with backtracking, like this, to return 4 different values: S color = "black" or "white"; S shape = "circle" or "square"; return "A " + color + " " + shape; */ svoid test_BStack_v2() { test_BStack_v2_oneBranch(); test_BStack_v2_twoBranches(); test_BStack_v2_undos(); test_BStack_v2_oneBranch3Options(); test_BStack_v2_twoBranches3Options(); test_BStack_v2_noOptions(); } svoid test_BStack_v2_oneBranch() { assertEqualsVerbose( ll("Color is black", "Color is white"), new BStackComputeAllWithPrintStruct(new BStack_v2, new test_BStack_OneBranch)!); } svoid test_BStack_v2_oneBranch3Options() { assertEqualsVerbose( ll("Color is black", "Color is white", "Color is gray"), new BStackComputeAllWithPrintStruct(new BStack_v2, new test_BStack_OneBranch3Options)!); } svoid test_BStack_v2_twoBranches() { assertEqualsVerbose( ll("A black circle", "A black square", "A white circle", "A white square"), new BStackComputeAllWithPrintStruct(new BStack_v2, new test_BStack_TwoBranches)!); } svoid test_BStack_v2_twoBranches3Options() { assertEqualsVerbose( ll("A black circle", "A black square", "A black triangle", "A white circle", "A white square", "A white triangle", "A gray circle", "A gray square", "A gray triangle"), new BStackComputeAllWithPrintStruct(new BStack_v2, new test_BStack_TwoBranches3Options)!); } svoid test_BStack_v2_undos() { new LS things; // list that is changed during execution to test the undos var stack = new BStack_v2<>(new test_BStack_TwoBranchesWithUndos(things)); for (S color : ll("black", "white")) for (S shape : ll("circle", "square")) { assertEqualsVerbose("A \*color*/ \*shape*/", stack.nextResultWithPrintStruct(10)); assertEqualsVerbose(ll(color, shape), things); stack = stack.backtrack(); } assertNull(stack);} svoid test_BStack_v2_noOptions() { assertInnerExceptionOfTypeVerbose(BStack_v2.NoOptionsException.class, -> new BStackComputeAllWithPrintStruct(new BStack_v2, new test_BStack_NoOptions)!); }
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: | 156 / 249 |
Version history: | 5 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) #1035399 - test_BStack_v3 (OK) #1035428 - test_PStack (OK) |