summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Kintel <marius@kintel.net>2012-01-03 19:34:31 (GMT)
committerMarius Kintel <marius@kintel.net>2012-01-03 19:34:31 (GMT)
commitfac508c8cd3ceef0f0abf1edb7f48f866d8a1232 (patch)
treeebb9a7b43a93f7b2853360711610d067c5137bef
parent597c5611072348d2d411d4f567fd8d0a46731628 (diff)
Added use-tests, minimal change to include-tests
-rw-r--r--testdata/scad/features/include-tests.scad4
-rw-r--r--testdata/scad/features/sub1/sub2/sub3/sub4/include-test2.scad4
-rw-r--r--testdata/scad/features/sub1/sub2/sub3/sub4/use-test2.scad14
-rw-r--r--testdata/scad/features/sub1/sub2/sub3/sub4/use-test3.scad4
-rw-r--r--testdata/scad/features/sub1/sub2/sub3/use-test4.scad4
-rw-r--r--testdata/scad/features/use test6.scad7
-rw-r--r--testdata/scad/features/use-test5.scad4
-rw-r--r--testdata/scad/features/use-tests.scad39
-rw-r--r--tests/CMakeLists.txt4
9 files changed, 80 insertions, 4 deletions
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 <non/existent/path/non-file>
//Test with empty path
include <include-test5.scad>
-//Test without preceeding space
+//Test without preceding space
include<include-test5.scad>
//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 <include-test3.scad>
//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 <use-test3.scad>
+
+//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 <sub1/sub2/sub3/sub4/use-test2.scad>
+
+//Test that a non existent path/file doesn't screw things up
+use <non/existent/path/non-file>
+
+//Test with empty path
+use <use-test5.scad>
+
+//Test without preceding space
+use<use-test5.scad>
+
+//Test with other strange character that is allowed
+use>>>>><use-test5.scad>
+
+//Test that filenames with spaces work
+use <use test6.scad>
+
+//Test with empty file
+use<test/>
+
+//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)
contact: Jan Huwald // Impressum