From d38d16ade9d5258d5cdab404533227fd5103c502 Mon Sep 17 00:00:00 2001 From: Mickey Rose Date: Thu, 2 Jan 2020 17:30:24 +0100 Subject: [PATCH] better tests for logical expressions Two of the original checks were not testing what they were supposed to test, because the result of eval didn't depend on correct parsing: eval("not true or not true") correct parse: ((not true) or (not true)) == false incorrect parse: (not (true or (not true))) == false eval("not false and not false") correct parse: ((not false) and (not false)) == true incorrect parse: (not (false and (not false))) == true --- test/unit/core/expressions_test.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/unit/core/expressions_test.cpp b/test/unit/core/expressions_test.cpp index 2f9e3823f..3e8720d59 100644 --- a/test/unit/core/expressions_test.cpp +++ b/test/unit/core/expressions_test.cpp @@ -153,10 +153,10 @@ TEST_CASE("expressions") // logical TRY_CHECK(eval(" [int] = 123 and [double] = 1.23456 && [bool] = true and [null] = null && [foo] = 'bar' ") == true); TRY_CHECK(eval(" [int] = 456 or [foo].match('foo') || length([foo]) = 3 ") == true); - TRY_CHECK(eval(" not true and not true ") == eval(" (not true ) and (not true ) ")); - TRY_CHECK(eval(" not true or not true ") == eval(" (not true ) or (not true ) ")); - TRY_CHECK(eval(" not false and not false ") == eval(" (not false) and (not false) ")); - TRY_CHECK(eval(" not false or not false ") == eval(" (not false) or (not false) ")); + TRY_CHECK(eval(" not true and not true ") == false); // (not true) and (not true) + TRY_CHECK(eval(" not false and not true ") == false); // (not false) and (not true) + TRY_CHECK(eval(" not true or not false ") == true); // (not true) or (not false) + TRY_CHECK(eval(" not false or not false ") == true); // (not false) or (not false) // test not/and/or precedence using combinations of "not EQ1 OP1 not EQ2 OP2 not EQ3" TRY_CHECK(eval(" not [grass] = 'grow' and not [wind] = 'blow' and not [sky] = 'is blue' ") == false);