add test for short circuit evaluation
diff --git a/test/test-functions.cpp b/test/test-functions.cpp
index 4870205..0f9b6c8 100644
--- a/test/test-functions.cpp
+++ b/test/test-functions.cpp
@@ -157,7 +157,7 @@
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");
}
diff --git a/test/test-renderer.cpp b/test/test-renderer.cpp
index fe38738..213722c 100644
--- a/test/test-renderer.cpp
+++ b/test/test-renderer.cpp
@@ -129,6 +129,12 @@
"[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!