ucg/integration_tests/select_expressions_test.ucg
Jeremy Wall d2f0ea9f24 FEATURE: Better error reporting.
Slight change to how assert works to support this. We no longer automatically add
a semicolon to the expressions we require the user to right them. This updates the
docs to illustrate that and reformats our integration test suite for this and
readability.
2018-11-06 19:40:56 -06:00

40 lines
660 B
Plaintext

let goodwant = "door1";
let badwant = "door4";
let got = select goodwant, "OOPS", {
door1 = "grand prize",
door2 = "you lose",
};
let defaultgot = select badwant, "OOPS", {
door1 = "grand prize",
door2 = "you lose",
};
assert |
got == "grand prize";
|;
assert |
defaultgot == "OOPS";
|;
// select inside a macro
let condmacro = macro(arg) => {
output = select arg, NULL, {
opt1 = "yay",
opt2 = "boo",
},
};
let result = condmacro("opt1");
assert |
condmacro("opt1") == {output = "yay"};
|;
assert |
condmacro("opt2") == {output = "boo"};
|;
assert |
condmacro("invalid") == {output = NULL};
|;