From 3780677def0ab71375f976efe0235c840dd02de2 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Thu, 9 May 2013 17:28:05 +0200 Subject: Added testcase for #322 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 -- cgit v0.10.1