scope test_PStack /* Goal: Allow probabilistic branching deep within nested function calls Like this, to return 4 different values: S color = "black" with probability 0.75 or "white" with probability 0.25; S shape = "circle" with probability 0.4 or "square" with probability 0.6; return "A " + color + " " + shape; */ sclass #C1 extends PStackComputableWithStep { S color; public void step(IPStack stack) { if (step == 0) { ++step; stack.options(this, ll( o -> o.color = "red", o -> o.color = "green")); } else stack.ret(color); } } please include function test_BStack. svoid test_PStack() { test_PStack_oneBranch(); test_PStack_twoBranches(); test_PStack_oneBranch3Options(); test_PStack_twoBranches3Options(); test_PStack_noOptions(); } svoid test_PStack_oneBranch() { assertEqualsVerbose( ll("Color is black", "Color is white"), pstackComputeAll(new test_BStack_OneBranch)); } svoid test_PStack_oneBranch3Options() { assertEqualsVerbose( ll("Color is black", "Color is white", "Color is gray"), pstackComputeAll(new test_BStack_OneBranch3Options)); } svoid test_PStack_twoBranches() { assertEqualsVerbose( ll("A black circle", "A black square", "A white circle", "A white square"), pstackComputeAll(new test_BStack_TwoBranches)); } svoid test_PStack_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"), pstackComputeAll(new test_BStack_TwoBranches3Options)); } svoid test_PStack_noOptions() { assertInnerExceptionOfTypeVerbose(PStack.NoOptionsException.class, -> pstackComputeAll(new test_BStack_NoOptions)); }