Skip to content

Commit

Permalink
add test for short circuit evaluation
Browse files Browse the repository at this point in the history
  • Loading branch information
pantor committed May 17, 2021
1 parent 389c1d6 commit ca3c7a0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion test/test-functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ TEST_CASE("functions") {
CHECK(env.render("{{ exists(\"zipcode\") }}", data) == "false");
CHECK(env.render("{{ exists(name) }}", data) == "false");
CHECK(env.render("{{ exists(property) }}", data) == "true");

// CHECK(env.render("{{ exists(\"keywords\") and length(keywords) > 0 }}", data) == "false");
}

Expand Down
6 changes: 6 additions & 0 deletions test/test-renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down

0 comments on commit ca3c7a0

Please sign in to comment.