diff options
-rw-r--r-- | testdata/scad/misc/expression-shortcircuit-tests.scad | 27 | ||||
-rw-r--r-- | tests/CMakeLists.txt | 3 | ||||
-rw-r--r-- | tests/regression/echotest/expression-shortcircuit-tests-expected.txt | 5 |
3 files changed, 34 insertions, 1 deletions
diff --git a/testdata/scad/misc/expression-shortcircuit-tests.scad b/testdata/scad/misc/expression-shortcircuit-tests.scad new file mode 100644 index 0000000..dd5a1d5 --- /dev/null +++ b/testdata/scad/misc/expression-shortcircuit-tests.scad @@ -0,0 +1,27 @@ +function foo() = search(undef,undef); + +if (false && foo()) { + echo("Fail"); +} else { + echo("Pass"); +} + +if (true || foo()) { + echo("Pass"); +} else { + echo("Fail"); +} + +if (true && true) { + echo("Pass"); +} + +if (false || true) { + echo("Pass"); +} + +function ternarytest() = true ? true : foo(); + +if (ternarytest()) { + echo("Pass"); +} diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 1bcd6c6..90d4998 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -779,7 +779,8 @@ list(APPEND ECHO_FILES ${FUNCTION_FILES} ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/value-reassignment-tests.scad ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/value-reassignment-tests2.scad ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/variable-scope-tests.scad - ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/lookup-tests.scad) + ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/lookup-tests.scad + ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/expression-shortcircuit-tests.scad) list(APPEND DUMPTEST_FILES ${FEATURES_FILES} ${EXAMPLE_FILES}) list(APPEND DUMPTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/escape-test.scad diff --git a/tests/regression/echotest/expression-shortcircuit-tests-expected.txt b/tests/regression/echotest/expression-shortcircuit-tests-expected.txt new file mode 100644 index 0000000..d7f1c40 --- /dev/null +++ b/tests/regression/echotest/expression-shortcircuit-tests-expected.txt @@ -0,0 +1,5 @@ +ECHO: "Pass" +ECHO: "Pass" +ECHO: "Pass" +ECHO: "Pass" +ECHO: "Pass" |