!include once #1034831 // Gazelle 22 Function Include for Testing svoid test_compiledLeftArrowScript() { embedded S countLoop(int n) { ret [[ i <- 0; while lessThan i ]] + n + [[ { i <- plus i 1 }; i ]]; } embedded void testScript(S script, O expectedValue) { var makeIF0 = leftArrowScriptToEvaluable(leftArrowParse(script)); makeIF0.printDisassembly(true); print(+script); assertEqualsVerbose(expectedValue, makeIF0!!); } // int primitive testScript([[ 5 ]], 5); testScript([[ -5 ]], -5); // double primitive testScript([[ str 1.5e2 ]], "150.0"); // new object with constructor arguments testScript([[ new Pair "hello" "world" ]], pair("hello", "world")); // assign & get variable testScript([[ i <- 23; i ]], 23); // while loop testScript(countLoop(5), 5); // conditional return testScript([[ if true { return "so true" } return "oops" ]], "so true"); testScript([[ if false { return "not true" } return "but this" ]], "but this"); }