Add test cases.

This commit is contained in:
Torsten Paul 2016-10-23 01:58:36 +02:00
parent 87adbd4363
commit 9df3a9f198
21 changed files with 110 additions and 2 deletions

View file

@ -0,0 +1,2 @@
v = assert(false);
echo(v);

View file

@ -0,0 +1,4 @@
a = 10;
b = 20;
v = assert(a < 20 && b < 20, "Test! <html>&</html>");
echo(v);

View file

@ -0,0 +1,7 @@
function f(x) = sin(x);
module m(angle) {
v = assert(f(angle) > 0) 10;
}
m(270);

View file

@ -0,0 +1,25 @@
a = 3;
b = 6;
t0 = assert(true);
echo(t0 = t0);
t1 = assert("t1");
echo(t1 = t1);
t2 = assert(a*b);
echo(t2 = t2);
t3 = assert(condition = a*b);
echo(t3 = t3);
t4 = assert(true) a*b;
echo(t4 = t4);
c = 2;
t5 = assert(condition = 2) a*b*c;
echo(t5 = t5);
d = c + 9;
t6 = assert(condition = d + 5 > 15, message = str("value: ", d + 5)) a*b*c*d;
echo(t6 = t6);

View file

@ -0,0 +1 @@
assert(false);

View file

@ -0,0 +1,3 @@
a = 10;
b = 20;
assert(a < 20 && b < 20, "Test! <html>&</html>");

View file

@ -0,0 +1,7 @@
function f(x) = sin(x);
module m(angle) {
assert(f(angle) > 0) cube(10);
}
m(270);

24
testdata/scad/misc/assert-tests.scad vendored Normal file
View file

@ -0,0 +1,24 @@
a = 3;
b = 6;
assert(true);
assert("t1");
assert(a*b);
assert(condition = a*b);
assert(true) cube(8, center = true);
c = 2;
translate([0, 20, 0])
assert(condition = 2)
sphere(5);
d = c + 9;
assert(condition = d + 5 > 15, message = str("value: ", d + 5))
translate([15, 0, 0])
cylinder(8, 5, center = true);
echo("assert-tests");

View file

@ -1032,7 +1032,7 @@ function(add_cmdline_test TESTCMD_BASENAME)
if (${EXPERIMENTAL} EQUAL -1)
set(EXPERIMENTAL_OPTION "")
else()
set(EXPERIMENTAL_OPTION "--enable=lc-each" "--enable=lc-else" "--enable=lc-for-c")
set(EXPERIMENTAL_OPTION "--enable=assert" "--enable=lc-each" "--enable=lc-else" "--enable=lc-for-c")
endif()
# 2D tests should be viewed from the top, not an angle.
@ -1161,6 +1161,10 @@ list(APPEND ECHO_FILES ${FUNCTION_FILES}
${CMAKE_SOURCE_DIR}/../testdata/scad/3D/features/for-tests.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/expression-evaluation-tests.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/echo-tests.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/assert-tests.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/assert-fail1-test.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/assert-fail2-test.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/assert-fail3-test.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/escape-test.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/parser-tests.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/builtin-tests.scad
@ -1205,6 +1209,7 @@ list(APPEND DUMPTEST_FILES ${FEATURES_2D_FILES} ${FEATURES_3D_FILES} ${DEPRECATE
list(APPEND DUMPTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/escape-test.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/include-tests.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/use-tests.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/assert-tests.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/let-module-tests.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/localfiles-test.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/localfiles_dir/localfiles-compatibility-test.scad
@ -1216,6 +1221,7 @@ list(APPEND CGALPNGTEST_2D_FILES ${FEATURES_2D_FILES} ${SCAD_DXF_FILES} ${EXAMPL
list(APPEND CGALPNGTEST_3D_FILES ${FEATURES_3D_FILES} ${DEPRECATED_3D_FILES} ${ISSUES_3D_FILES} ${EXAMPLE_3D_FILES})
list(APPEND CGALPNGTEST_3D_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/include-tests.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/use-tests.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/assert-tests.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/let-module-tests.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/transform-nan-inf-tests.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/localfiles-test.scad
@ -1350,7 +1356,20 @@ disable_tests(csgpngtest_primitive-inf-tests
cgalpngtest_empty-shape-tests
csgpngtest_issue1258)
experimental_tests(echotest_list-comprehensions-experimental)
experimental_tests(echotest_list-comprehensions-experimental
echotest_assert-tests
cgalpngtest_assert-tests
opencsgtest_assert-tests
csgpngtest_assert-tests
throwntogethertest_assert-tests
echotest_assert-fail1-test
echotest_assert-fail2-test
echotest_assert-fail3-test
echotest_echo-expression-tests
echotest_assert-expression-tests
echotest_assert-expression-fail1-test
echotest_assert-expression-fail2-test
echotest_assert-expression-fail3-test)
# Test config handling

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

View file

@ -0,0 +1,2 @@
multmatrix([[1, 0, 0, 0], [0, 1, 0, 20], [0, 0, 1, 0], [0, 0, 0, 1]]);
group();

View file

@ -0,0 +1 @@
ERROR: Assertion 'false' failed, line 1

View file

@ -0,0 +1 @@
ERROR: Assertion '((a < 20) && (b < 20))' failed, line 3: "Test! <html>&</html>"

View file

@ -0,0 +1 @@
ERROR: Assertion '(f(angle) > 0)' failed, line 4

View file

@ -0,0 +1,7 @@
ECHO: t0 = undef
ECHO: t1 = undef
ECHO: t2 = undef
ECHO: t3 = undef
ECHO: t4 = 18
ECHO: t5 = 36
ECHO: t6 = 396

View file

@ -0,0 +1 @@
ERROR: Assertion 'false' failed, line 1

View file

@ -0,0 +1 @@
ERROR: Assertion '((a < 20) && (b < 20))' failed, line 3: "Test! <html>&</html>"

View file

@ -0,0 +1 @@
ERROR: Assertion '(f(angle) > 0)' failed, line 4

View file

@ -0,0 +1 @@
ECHO: "assert-tests"

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB