add test for short circuit evaluation

This commit is contained in:
pantor
2021-05-17 20:03:17 +02:00
parent 389c1d64f0
commit ca3c7a0cd6
2 changed files with 7 additions and 1 deletions

View File

@@ -129,6 +129,12 @@ TEST_CASE("types") {
"[inja.exception.render_error] (at 1:7) variable 'predefined' not found");
}
SUBCASE("short circuit evaluation") {
CHECK(env.render("{% if 0 and undefined %}do{% else %}nothing{% endif %}", data) == "nothing");
CHECK_THROWS_WITH(env.render("{% if 1 and undefined %}do{% else %}nothing{% endif %}", data),
"[inja.exception.render_error] (at 1:13) variable 'undefined' not found");
}
SUBCASE("line statements") {
CHECK(env.render(R""""(## if is_happy
Yeah!