mirror of
https://github.com/zaphar/ucg.git
synced 2025-07-22 18:19:54 -04:00
FEATURE: Support boolean and EMPTY as a format string variable.
Also add format string regression tests.
This commit is contained in:
parent
aa88f5a196
commit
3ed8fe332f
4
integration_tests/format_test.ucg
Normal file
4
integration_tests/format_test.ucg
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
assert |"hello @" % ("world") == "hello world"|;
|
||||||
|
assert |"1 @ @" % (2, 3) == "1 2 3"|;
|
||||||
|
assert |"@ or @" % (true, false) == "true or false"|;
|
||||||
|
assert |"@" % (NULL) == "NULL"|;
|
@ -73,3 +73,8 @@ fn test_concatenation() {
|
|||||||
"../../integration_tests/concatenation_test.ucg"
|
"../../integration_tests/concatenation_test.ucg"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_format() {
|
||||||
|
assert_build(include_str!("../../integration_tests/format_test.ucg"));
|
||||||
|
}
|
||||||
|
@ -276,6 +276,8 @@ impl From<Val> for String {
|
|||||||
Val::Int(ref i) => format!("{}", i),
|
Val::Int(ref i) => format!("{}", i),
|
||||||
Val::Float(ref f) => format!("{}", f),
|
Val::Float(ref f) => format!("{}", f),
|
||||||
Val::Str(ref s) => s.to_string(),
|
Val::Str(ref s) => s.to_string(),
|
||||||
|
Val::Boolean(ref b) => format!("{}", b),
|
||||||
|
Val::Empty => "NULL".to_string(),
|
||||||
val => format!("<{}>", val),
|
val => format!("<{}>", val),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user