From 38cb06c3f0c62cbbe911a1543128bde610c45031 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Mon, 4 Jun 2012 11:22:09 +0200 Subject: Added test cases for issue #123 diff --git a/testdata/scad/features/import_dxf-tests.scad b/testdata/scad/features/import_dxf-tests.scad index 736f26e..50a5416 100644 --- a/testdata/scad/features/import_dxf-tests.scad +++ b/testdata/scad/features/import_dxf-tests.scad @@ -7,3 +7,4 @@ translate([-200,200,0]) import(file="../../dxf/multiple-layers.dxf", layer="0"); translate([0,200,0]) import(file="../../dxf/multiple-layers.dxf", layer="0"); translate([200,200,0]) import(file="../../dxf/multiple-layers.dxf", layer="noname"); translate([0,200,0]) import(file="../../dxf/multiple-layers.dxf", layer="Layer with a pretty long name including \\ \"special\" /'\\\\ characters"); +translate([200,0,0]) import(file="/Users/kintel/code/OpenSCAD/openscad/tests/../testdata/dxf/polygons.dxf"); diff --git a/testdata/scad/features/import_stl-tests.scad b/testdata/scad/features/import_stl-tests.scad index 7104078..af42e8d 100644 --- a/testdata/scad/features/import_stl-tests.scad +++ b/testdata/scad/features/import_stl-tests.scad @@ -1,3 +1,4 @@ import_stl("import.stl"); translate([2,0,0]) import("import.stl"); translate([4,0,0]) import("import_bin.stl"); +translate([0,2,0]) import("/Users/kintel/code/OpenSCAD/openscad/tests/../testdata/scad/features/import.stl"); diff --git a/testdata/scad/misc/include-tests-template.scad b/testdata/scad/misc/include-tests-template.scad deleted file mode 100644 index 43bda57..0000000 --- a/testdata/scad/misc/include-tests-template.scad +++ /dev/null @@ -1,55 +0,0 @@ -//Test that the entire path is pushed onto the stack upto the last '/' -include - -//Test that a non existent path/file doesn't screw things up -include - -//Test with empty path -include - -//Test without preceding space -include - -//Test with other strange character that is allowed -include>>>>> - -//Test that filenames with spaces work -include - -//Test with empty file -include - -//Test with empty path and file -include - -//Test with absolute path -include <@CMAKE_SOURCE_DIR@/../testdata/scad/misc/sub2/test7.scad> - -// Test simple MCAD include -include - -// Test MCAD include which includes another file -include - -// Test MCAD include which uses another file -include - -module test1() -{ - test2(); - translate([2,0,0]) test3(); - translate([2,-2,0]) test4(); - translate([-2,0,0]) test5(); - translate([-2,-2,0]) test6(); - translate([0,2,0]) test7(); - - //Just to give a top level object - translate([0,-2,0]) sphere(test2_variable, $fn=16); - - // MCAD - translate([0,-4,0]) cube([TAU/4,0.5,0.5], center=true); - translate([-2,-4,0]) cube([deg(0.5)/20,0.5,0.5], center=true); - translate([2,-4,-0.5]) scale(0.05) alignds420([0,0,0], [0,0,0]); -} - -test1(); diff --git a/testdata/scad/misc/use-tests-template.scad b/testdata/scad/misc/use-tests-template.scad deleted file mode 100644 index 24591f8..0000000 --- a/testdata/scad/misc/use-tests-template.scad +++ /dev/null @@ -1,57 +0,0 @@ -//Test that the entire path is pushed onto the stack upto the last '/' -use - -//Test that a non existent path/file doesn't screw things up -use - -//Test with empty path -use - -//Test without preceding space -use - -//Test with other strange character that is allowed -use>>>>> - -//Test that filenames with spaces work -use - -//Test with empty file -use - -//Test with empty path and file -use - -//Test with absolute path -include <@CMAKE_SOURCE_DIR@/../testdata/scad/misc/sub2/test7.scad> - -// Test simple MCAD library -include - -// Test MCAD library which includes another file -include - -// Test MCAD library which uses another file -include - -module test1() -{ - test2(); - // test3() and test4() are not directly included and thus not imported into - // this scope - translate([4,0,0]) test3(); - translate([4,-2,0]) test4(); - translate([-2,0,0]) test5(); - translate([-2,-2,0]) test6(); - translate([0,2,0]) test7(); - - // test2_variable won't be visible - translate([0,-2,0]) sphere(test2_variable, $fn=16); - - // MCAD - translate([0,-4,0]) teardrop(0.3, 1.5, 90); - translate([-2,-4,0]) cube([deg(0.5)/20,0.5,0.5], center=true); - translate([2,-4,-0.5]) scale(0.05) alignds420([0,0,0], [0,0,0]); -} - -test1(); diff --git a/testdata/scad/templates/import_dxf-tests-template.scad b/testdata/scad/templates/import_dxf-tests-template.scad new file mode 100644 index 0000000..f10dd06 --- /dev/null +++ b/testdata/scad/templates/import_dxf-tests-template.scad @@ -0,0 +1,10 @@ +import(); +translate([-210,0,0]) import(file="../../dxf/polygons.dxf"); +translate([-210,0,0]) import(file="../../dxf/polygons.dxf", origin=[0,110]); +translate([-210,0,0]) import(file="../../dxf/polygons.dxf", origin=[110,110], scale=0.5); +import(file="../../dxf/multiple-layers.dxf"); +translate([-200,200,0]) import(file="../../dxf/multiple-layers.dxf", layer="0"); +translate([0,200,0]) import(file="../../dxf/multiple-layers.dxf", layer="0"); +translate([200,200,0]) import(file="../../dxf/multiple-layers.dxf", layer="noname"); +translate([0,200,0]) import(file="../../dxf/multiple-layers.dxf", layer="Layer with a pretty long name including \\ \"special\" /'\\\\ characters"); +translate([200,0,0]) import(file="@CMAKE_SOURCE_DIR@/../testdata/dxf/polygons.dxf"); diff --git a/testdata/scad/templates/import_stl-tests-template.scad b/testdata/scad/templates/import_stl-tests-template.scad new file mode 100644 index 0000000..685b868 --- /dev/null +++ b/testdata/scad/templates/import_stl-tests-template.scad @@ -0,0 +1,4 @@ +import_stl("import.stl"); +translate([2,0,0]) import("import.stl"); +translate([4,0,0]) import("import_bin.stl"); +translate([0,2,0]) import("@CMAKE_SOURCE_DIR@/../testdata/scad/features/import.stl"); diff --git a/testdata/scad/templates/include-tests-template.scad b/testdata/scad/templates/include-tests-template.scad new file mode 100644 index 0000000..43bda57 --- /dev/null +++ b/testdata/scad/templates/include-tests-template.scad @@ -0,0 +1,55 @@ +//Test that the entire path is pushed onto the stack upto the last '/' +include + +//Test that a non existent path/file doesn't screw things up +include + +//Test with empty path +include + +//Test without preceding space +include + +//Test with other strange character that is allowed +include>>>>> + +//Test that filenames with spaces work +include + +//Test with empty file +include + +//Test with empty path and file +include + +//Test with absolute path +include <@CMAKE_SOURCE_DIR@/../testdata/scad/misc/sub2/test7.scad> + +// Test simple MCAD include +include + +// Test MCAD include which includes another file +include + +// Test MCAD include which uses another file +include + +module test1() +{ + test2(); + translate([2,0,0]) test3(); + translate([2,-2,0]) test4(); + translate([-2,0,0]) test5(); + translate([-2,-2,0]) test6(); + translate([0,2,0]) test7(); + + //Just to give a top level object + translate([0,-2,0]) sphere(test2_variable, $fn=16); + + // MCAD + translate([0,-4,0]) cube([TAU/4,0.5,0.5], center=true); + translate([-2,-4,0]) cube([deg(0.5)/20,0.5,0.5], center=true); + translate([2,-4,-0.5]) scale(0.05) alignds420([0,0,0], [0,0,0]); +} + +test1(); diff --git a/testdata/scad/templates/use-tests-template.scad b/testdata/scad/templates/use-tests-template.scad new file mode 100644 index 0000000..24591f8 --- /dev/null +++ b/testdata/scad/templates/use-tests-template.scad @@ -0,0 +1,57 @@ +//Test that the entire path is pushed onto the stack upto the last '/' +use + +//Test that a non existent path/file doesn't screw things up +use + +//Test with empty path +use + +//Test without preceding space +use + +//Test with other strange character that is allowed +use>>>>> + +//Test that filenames with spaces work +use + +//Test with empty file +use + +//Test with empty path and file +use + +//Test with absolute path +include <@CMAKE_SOURCE_DIR@/../testdata/scad/misc/sub2/test7.scad> + +// Test simple MCAD library +include + +// Test MCAD library which includes another file +include + +// Test MCAD library which uses another file +include + +module test1() +{ + test2(); + // test3() and test4() are not directly included and thus not imported into + // this scope + translate([4,0,0]) test3(); + translate([4,-2,0]) test4(); + translate([-2,0,0]) test5(); + translate([-2,-2,0]) test6(); + translate([0,2,0]) test7(); + + // test2_variable won't be visible + translate([0,-2,0]) sphere(test2_variable, $fn=16); + + // MCAD + translate([0,-4,0]) teardrop(0.3, 1.5, 90); + translate([-2,-4,0]) cube([deg(0.5)/20,0.5,0.5], center=true); + translate([2,-4,-0.5]) scale(0.05) alignds420([0,0,0], [0,0,0]); +} + +test1(); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 569f631..5ec8be7 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -611,10 +611,14 @@ endforeach() set_directory_properties(PROPERTIES TEST_INCLUDE_FILE "${CMAKE_SOURCE_DIR}/EnforceConfig.cmake") # Subst files -configure_file(${CMAKE_SOURCE_DIR}/../testdata/scad/misc/include-tests-template.scad +configure_file(${CMAKE_SOURCE_DIR}/../testdata/scad/templates/include-tests-template.scad ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/include-tests.scad) -configure_file(${CMAKE_SOURCE_DIR}/../testdata/scad/misc/use-tests-template.scad +configure_file(${CMAKE_SOURCE_DIR}/../testdata/scad/templates/use-tests-template.scad ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/use-tests.scad) +configure_file(${CMAKE_SOURCE_DIR}/../testdata/scad/templates/import_stl-tests-template.scad + ${CMAKE_SOURCE_DIR}/../testdata/scad/features/import_stl-tests.scad) +configure_file(${CMAKE_SOURCE_DIR}/../testdata/scad/templates/import_dxf-tests-template.scad + ${CMAKE_SOURCE_DIR}/../testdata/scad/features/import_dxf-tests.scad) # Find all scad files file(GLOB MINIMAL_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/minimal/*.scad) diff --git a/tests/regression/cgalpngtest/import_dxf-tests-expected.png b/tests/regression/cgalpngtest/import_dxf-tests-expected.png index 7c8a63e..f885b09 100644 Binary files a/tests/regression/cgalpngtest/import_dxf-tests-expected.png and b/tests/regression/cgalpngtest/import_dxf-tests-expected.png differ diff --git a/tests/regression/cgalpngtest/import_stl-tests-expected.png b/tests/regression/cgalpngtest/import_stl-tests-expected.png index 08aa225..de7638a 100644 Binary files a/tests/regression/cgalpngtest/import_stl-tests-expected.png and b/tests/regression/cgalpngtest/import_stl-tests-expected.png differ diff --git a/tests/regression/dumptest/import_dxf-tests-expected.txt b/tests/regression/dumptest/import_dxf-tests-expected.txt index 977efcc..d98b3e2 100644 --- a/tests/regression/dumptest/import_dxf-tests-expected.txt +++ b/tests/regression/dumptest/import_dxf-tests-expected.txt @@ -21,4 +21,7 @@ multmatrix([[1, 0, 0, 0], [0, 1, 0, 200], [0, 0, 1, 0], [0, 0, 0, 1]]) { import(file = "../../dxf/multiple-layers.dxf", layer = "Layer with a pretty long name including \\ \"special\" /'\\\\ characters", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2); } + multmatrix([[1, 0, 0, 200], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + import(file = "../../dxf/polygons.dxf", layer = "", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2); + } diff --git a/tests/regression/dumptest/import_stl-tests-expected.txt b/tests/regression/dumptest/import_stl-tests-expected.txt index 648a207..947f137 100644 --- a/tests/regression/dumptest/import_stl-tests-expected.txt +++ b/tests/regression/dumptest/import_stl-tests-expected.txt @@ -5,4 +5,7 @@ multmatrix([[1, 0, 0, 4], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { import(file = "import_bin.stl", layer = "", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2); } + multmatrix([[1, 0, 0, 0], [0, 1, 0, 2], [0, 0, 1, 0], [0, 0, 0, 1]]) { + import(file = "import.stl", layer = "", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2); + } diff --git a/tests/regression/opencsgtest/import_dxf-tests-expected.png b/tests/regression/opencsgtest/import_dxf-tests-expected.png index 6e568c7..010a222 100644 Binary files a/tests/regression/opencsgtest/import_dxf-tests-expected.png and b/tests/regression/opencsgtest/import_dxf-tests-expected.png differ diff --git a/tests/regression/opencsgtest/import_stl-tests-expected.png b/tests/regression/opencsgtest/import_stl-tests-expected.png index 19e233a..0bd9ab6 100644 Binary files a/tests/regression/opencsgtest/import_stl-tests-expected.png and b/tests/regression/opencsgtest/import_stl-tests-expected.png differ diff --git a/tests/regression/throwntogethertest/import_dxf-tests-expected.png b/tests/regression/throwntogethertest/import_dxf-tests-expected.png index e8173d9..f5ef9fc 100644 Binary files a/tests/regression/throwntogethertest/import_dxf-tests-expected.png and b/tests/regression/throwntogethertest/import_dxf-tests-expected.png differ diff --git a/tests/regression/throwntogethertest/import_stl-tests-expected.png b/tests/regression/throwntogethertest/import_stl-tests-expected.png index 19e233a..0bd9ab6 100644 Binary files a/tests/regression/throwntogethertest/import_stl-tests-expected.png and b/tests/regression/throwntogethertest/import_stl-tests-expected.png differ -- cgit v0.10.1