From ca3c7a0cd6672ce114adb08f3f0083f8d6c46478 Mon Sep 17 00:00:00 2001 From: pantor Date: Mon, 17 May 2021 20:03:17 +0200 Subject: [PATCH] add test for short circuit evaluation --- test/test-functions.cpp | 2 +- test/test-renderer.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) 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 @@ 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"); } 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 @@ 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!