From fac508c8cd3ceef0f0abf1edb7f48f866d8a1232 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Tue, 3 Jan 2012 20:34:31 +0100 Subject: Added use-tests, minimal change to include-tests diff --git a/testdata/scad/features/include-tests.scad b/testdata/scad/features/include-tests.scad index 36c04ca..fc4e9d0 100644 --- a/testdata/scad/features/include-tests.scad +++ b/testdata/scad/features/include-tests.scad @@ -7,7 +7,7 @@ include //Test with empty path include -//Test without preceeding space +//Test without preceding space include //Test with other strange character that is allowed @@ -34,7 +34,7 @@ module test1() translate([-2,-2,0]) test6(); //Just to give a top level object - translate([0,-2,0]) sphere(0.7, $fn=16); + translate([0,-2,0]) sphere(test2_variable, $fn=16); } test1(); diff --git a/testdata/scad/features/sub1/sub2/sub3/sub4/include-test2.scad b/testdata/scad/features/sub1/sub2/sub3/sub4/include-test2.scad index 140c4ed..c34632c 100644 --- a/testdata/scad/features/sub1/sub2/sub3/sub4/include-test2.scad +++ b/testdata/scad/features/sub1/sub2/sub3/sub4/include-test2.scad @@ -4,7 +4,9 @@ include //Test relative file location include <../include-test4.scad> -module test2 () +test2_variable = 0.7; + +module test2() { cube(center=true); } diff --git a/testdata/scad/features/sub1/sub2/sub3/sub4/use-test2.scad b/testdata/scad/features/sub1/sub2/sub3/sub4/use-test2.scad new file mode 100644 index 0000000..68013db --- /dev/null +++ b/testdata/scad/features/sub1/sub2/sub3/sub4/use-test2.scad @@ -0,0 +1,14 @@ +//Test nested use +use + +//Test relative file location +use <../use-test4.scad> + +test2_variable = 0.7; + +module test2() +{ + translate([2,0,0]) test3(); + translate([2,-2,0]) test4(); + cube(center=true); +} diff --git a/testdata/scad/features/sub1/sub2/sub3/sub4/use-test3.scad b/testdata/scad/features/sub1/sub2/sub3/sub4/use-test3.scad new file mode 100644 index 0000000..6e3537e --- /dev/null +++ b/testdata/scad/features/sub1/sub2/sub3/sub4/use-test3.scad @@ -0,0 +1,4 @@ +module test3() +{ + cylinder(r1=0.7, r2=0.2, center=true); +} diff --git a/testdata/scad/features/sub1/sub2/sub3/use-test4.scad b/testdata/scad/features/sub1/sub2/sub3/use-test4.scad new file mode 100644 index 0000000..c13368c --- /dev/null +++ b/testdata/scad/features/sub1/sub2/sub3/use-test4.scad @@ -0,0 +1,4 @@ +module test4() +{ + cylinder(r=0.5, $fn=10, center=true); +} diff --git a/testdata/scad/features/use test6.scad b/testdata/scad/features/use test6.scad new file mode 100644 index 0000000..0d96b26 --- /dev/null +++ b/testdata/scad/features/use test6.scad @@ -0,0 +1,7 @@ +module test6() +{ + difference() { + cube(center=true); + cylinder(r=0.4, h=2, center=true); + } +} diff --git a/testdata/scad/features/use-test5.scad b/testdata/scad/features/use-test5.scad new file mode 100644 index 0000000..e4393cb --- /dev/null +++ b/testdata/scad/features/use-test5.scad @@ -0,0 +1,4 @@ +module test5() +{ + sphere(r=0.5, $fn=8); +} diff --git a/testdata/scad/features/use-tests.scad b/testdata/scad/features/use-tests.scad new file mode 100644 index 0000000..64af692 --- /dev/null +++ b/testdata/scad/features/use-tests.scad @@ -0,0 +1,39 @@ +//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 + +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(); + + // test2_variable won't be visible + translate([0,-2,0]) sphere(test2_variable, $fn=16); +} + +test1(); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index cdcc0c0..13d3b37 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -547,7 +547,9 @@ file(GLOB FEATURES_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/features/*.scad) # Remove included files not to be used as tests list(REMOVE_ITEM FEATURES_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/features/include\ test6.scad - ${CMAKE_SOURCE_DIR}/../testdata/scad/features/include-test5.scad) + ${CMAKE_SOURCE_DIR}/../testdata/scad/features/include-test5.scad + ${CMAKE_SOURCE_DIR}/../testdata/scad/features/use\ test6.scad + ${CMAKE_SOURCE_DIR}/../testdata/scad/features/use-test5.scad) file(GLOB BUGS_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/*.scad) file(GLOB SCAD_DXF_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/dxf/*.scad) file(GLOB FUNCTION_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/functions/*.scad) -- cgit v0.10.1