diff --git a/integration_tests/format_test.ucg b/integration_tests/format_test.ucg new file mode 100644 index 0000000..e2d825f --- /dev/null +++ b/integration_tests/format_test.ucg @@ -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"|; \ No newline at end of file diff --git a/src/build/compile_test.rs b/src/build/compile_test.rs index f893ac1..00495c0 100644 --- a/src/build/compile_test.rs +++ b/src/build/compile_test.rs @@ -73,3 +73,8 @@ fn test_concatenation() { "../../integration_tests/concatenation_test.ucg" )); } + +#[test] +fn test_format() { + assert_build(include_str!("../../integration_tests/format_test.ucg")); +} diff --git a/src/build/mod.rs b/src/build/mod.rs index 0e19110..32152a9 100644 --- a/src/build/mod.rs +++ b/src/build/mod.rs @@ -276,6 +276,8 @@ impl From for String { Val::Int(ref i) => format!("{}", i), Val::Float(ref f) => format!("{}", f), Val::Str(ref s) => s.to_string(), + Val::Boolean(ref b) => format!("{}", b), + Val::Empty => "NULL".to_string(), val => format!("<{}>", val), } }