diff options
author | Marius Kintel <marius@kintel.net> | 2013-05-09 15:28:05 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2013-05-09 15:28:05 (GMT) |
commit | 3780677def0ab71375f976efe0235c840dd02de2 (patch) | |
tree | 5b1c9b7730ab22e53c39e46f2a8131456d95dc81 | |
parent | 715d539f4ea1a37833ab2429262593aee57304fe (diff) |
Added testcase for #322
-rw-r--r-- | testdata/scad/misc/lookup-tests.scad | 17 | ||||
-rw-r--r-- | tests/CMakeLists.txt | 3 | ||||
-rw-r--r-- | tests/regression/echotest/lookup-tests-expected.txt | 15 |
3 files changed, 34 insertions, 1 deletions
diff --git a/testdata/scad/misc/lookup-tests.scad b/testdata/scad/misc/lookup-tests.scad new file mode 100644 index 0000000..c03ec95 --- /dev/null +++ b/testdata/scad/misc/lookup-tests.scad @@ -0,0 +1,17 @@ +echo(lookup(undef, undef)); +echo(lookup(undef, [undef])); +echo(lookup(undef, [[undef]])); +echo(lookup(undef, [[undef, undef]])); +echo(lookup(0, [[0, 0]])); +echo(lookup(0.5, [[0, 0], + [1, 1]])); + +table = [[-1, -5], + [-10, -55], + [0, 0], + [1, 3], + [10, 333]]; +indices = [-20,-10,-9.9, -0.5, 0, 0.3, 1.1, 10, 10.1]; +for (i=[0:len(indices)-1]) { + echo(lookup(indices[i], table)); +} diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 964adc2..38b2758 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -757,7 +757,8 @@ list(APPEND ECHO_FILES ${FUNCTION_FILES} ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/search-tests.scad ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/recursion-tests.scad ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/value-reassignment-tests.scad - ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/variable-scope-tests.scad) + ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/variable-scope-tests.scad + ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/lookup-tests.scad) list(APPEND DUMPTEST_FILES ${MINIMAL_FILES} ${FEATURES_FILES} ${EXAMPLE_FILES}) list(APPEND DUMPTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/escape-test.scad diff --git a/tests/regression/echotest/lookup-tests-expected.txt b/tests/regression/echotest/lookup-tests-expected.txt new file mode 100644 index 0000000..b98ebe2 --- /dev/null +++ b/tests/regression/echotest/lookup-tests-expected.txt @@ -0,0 +1,15 @@ +ECHO: undef +ECHO: undef +ECHO: undef +ECHO: undef +ECHO: 0 +ECHO: 0.5 +ECHO: -55 +ECHO: -55 +ECHO: -54.44444444444 +ECHO: -2.5 +ECHO: 0 +ECHO: 0.9 +ECHO: 6.66666666666 +ECHO: 333 +ECHO: 333 |