mirror of
https://github.com/zaphar/ucg.git
synced 2025-07-22 18:19:54 -04:00
TESTS: Add select expression integration tests.
This commit is contained in:
parent
a7a32d56b2
commit
523e2db483
30
integration_tests/select_expressions_test.ucg
Normal file
30
integration_tests/select_expressions_test.ucg
Normal 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}|;
|
@ -48,6 +48,13 @@ fn test_empty_value() {
|
|||||||
assert_build(include_str!("../../integration_tests/empty_test.ucg"));
|
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]
|
#[test]
|
||||||
fn test_binary_operator_precedence() {
|
fn test_binary_operator_precedence() {
|
||||||
assert_build(include_str!(
|
assert_build(include_str!(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user