mirror of
https://github.com/polserver/polserver
synced 2026-08-13 08:23:08 -04:00
* Grammar update * AST generation * Emit instructions * Add initial tests * Additional tests * Rename to ConditionalOperator * Add docs
29 lines
586 B
Text
29 lines
586 B
Text
function Call(byref val)
|
|
return ++val;
|
|
endfunction
|
|
|
|
function DoNotCall()
|
|
print("TEST FAILURE");
|
|
return error{ errortext := "Called!" };
|
|
endfunction
|
|
|
|
var foo, i := 0;
|
|
|
|
foo := 1 ? Call(i) : DoNotCall();
|
|
print(foo);
|
|
|
|
foo := 0 ? DoNotCall() : Call(i);
|
|
print(foo);
|
|
|
|
foo := -1 > 0 ? DoNotCall() : Call(i);
|
|
print(foo);
|
|
|
|
foo := -1 > 0 ? DoNotCall() : 0 > 1 ? DoNotCall() : Call(i);
|
|
print(foo);
|
|
|
|
foo := 0 ?: "" ? DoNotCall() : Unpack("u") ?: 0 ? DoNotCall() : Call(i);
|
|
print(foo);
|
|
|
|
var bar := struct{};
|
|
foo := bar.+baz := "" ?: "truthty" ? 1 : 0 ? Call(i) : DoNotCall();
|
|
print(foo);
|