mirror of
https://github.com/zaphar/ucg.git
synced 2025-07-22 18:19:54 -04:00
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.
40 lines
660 B
Plaintext
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};
|
|
|; |