Warning: session_start(): open(/var/lib/php/sessions/sess_qb9t33qefl6vb43a72l2hisvdu, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
!include once #1034034 // Gazelle 22 Function Include for Scripts
set flag PingV3.
set flag ReturnFromScript_debug.
scope test_leftArrowScript
sclass #Tester { O value = "123"; }
svoid test_leftArrowScript() {
test_leftArrowScript_pinging();
embedded S countLoop(int n) {
ret [[ i <- 0; while lessThan i ]] + n + [[ { i <- plus i 1 }; i ]];
}
testFunctionValues(script -> leftArrowVerbose((S) script),
// int primitive
[[ 5 ]], 5,
[[ -5 ]], -5,
// function definition & call
[[
def double x {
Math multiplyExact x 2
}
double 10
]], 20,
// new object with constructor arguments
[[ new Pair "hello" "world" ]], pair("hello", "world"),
// double primitive
[[ str 1.5e2 ]], "150.0",
// [not implemented, too complicated]
// last = result of last statement
// [[ plus 1 2; Math addExact 5 last ]], 8,
// get static field
[[ Color black ]], Color.black,
// get instance field,
[[ tester <- new test_leftArrowScript_Tester; tester value ]], "123",
// while loop
countLoop(5), 5,
// if statement
[[ if lessThan 0 1 { "ok" } ]], "ok",
[[ if lessThan 1 0 { "ok" } ]], null,
// for each
[[ l <- ll 2 3
sum <- 0
for number in l { sum <- plus sum number }
sum
]], 5,
// some bug
[[
img <- newImage 10 10
r <- randomRect img 10 10
]], rect(0, 0, 10, 10),
// another bug
[[
a <- 1
b <- a
a
]], 1,
// null bug
[[
a <- 1
a <- null
a
]], null,
// return at the end
[[
return 17
]], 17,
// two returns (first wins)
[[
return 13
return 22
]], 13,
// conditional return
[[
if true { return "so true" }
return "oops"
]], "so true",
// nested expressions
[[ plus (plus 1 2) 4 ]], 7,
[[ (plus 5 6) toString ]], "11",
// nested expressions over 2 lines (it's ok to split an expression
// over multiple lines if you at least parenthesis is still open)
[[ (plus 1
(plus 2 3)) ]], 6,
// another case for nested expressions
[[ str (Color black) ]], str(Color.black),
);
// add more tests here
print("All left-arrow script tests OK!");
}