TESTS: Add select expression integration tests.

This commit is contained in:
Jeremy Wall 2018-08-20 23:05:34 -05:00
parent a7a32d56b2
commit 523e2db483
2 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,30 @@
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}|;

View File

@ -48,6 +48,13 @@ fn test_empty_value() {
assert_build(include_str!("../../integration_tests/empty_test.ucg"));
}
#[test]
fn test_select_expressions() {
assert_build(include_str!(
"../../integration_tests/select_expressions_test.ucg"
));
}
#[test]
fn test_binary_operator_precedence() {
assert_build(include_str!(