diff options
Diffstat (limited to 'testdata')
-rwxr-xr-x | testdata/modulecache-tests/cascade.sh | 2 | ||||
-rwxr-xr-x | testdata/modulecache-tests/cascade2.sh | 2 | ||||
-rw-r--r-- | testdata/scad/dxf/arc.scad | 1 | ||||
-rw-r--r-- | testdata/scad/dxf/circle.scad | 1 | ||||
-rw-r--r-- | testdata/scad/features/circle-tests.scad | 1 | ||||
-rw-r--r-- | testdata/scad/features/cylinder-tests.scad | 4 | ||||
-rw-r--r-- | testdata/scad/features/linear_extrude-tests.scad | 3 | ||||
-rw-r--r-- | testdata/scad/features/rotate_extrude-tests.scad | 4 | ||||
-rw-r--r-- | testdata/scad/features/sphere-tests.scad | 1 | ||||
-rw-r--r-- | testdata/scad/misc/value-reassignment-tests.scad | 9 | ||||
-rw-r--r-- | testdata/scad/misc/value-reassignment-tests2.scad | 16 | ||||
-rw-r--r-- | testdata/scad/misc/variable-scope-tests.scad | 13 |
12 files changed, 50 insertions, 7 deletions
diff --git a/testdata/modulecache-tests/cascade.sh b/testdata/modulecache-tests/cascade.sh index 5dd0ef7..3193d06 100755 --- a/testdata/modulecache-tests/cascade.sh +++ b/testdata/modulecache-tests/cascade.sh @@ -1,6 +1,6 @@ #!/bin/bash -rm cascade*.scad +rm -f cascade*.scad echo "include <cascade-A.scad> include <cascade-B.scad> use <cascade-C.scad> use <cascade-D.scad> A(); translate([11,0,0]) B(); translate([22,0,0]) C(); translate([33,0,0]) D();" > cascadetest.scad sleep 0.05 echo "module A() { sphere(5); }" > cascade-A.scad diff --git a/testdata/modulecache-tests/cascade2.sh b/testdata/modulecache-tests/cascade2.sh index 50f98e0..4969e6f 100755 --- a/testdata/modulecache-tests/cascade2.sh +++ b/testdata/modulecache-tests/cascade2.sh @@ -1,6 +1,6 @@ #!/bin/bash -rm cascade-*.scad +rm -f cascade-*.scad echo "include <cascade-A.scad> include <cascade-B.scad> use <cascade-C.scad> use <cascade-D.scad> A(); translate([11,0,0]) B(); translate([22,0,0]) C(); translate([33,0,0]) D();" > cascadetest.scad sleep 0.1 echo "module A() { sphere(6); }" > cascade-A.scad diff --git a/testdata/scad/dxf/arc.scad b/testdata/scad/dxf/arc.scad index fff70a3..f53b7bd 100644 --- a/testdata/scad/dxf/arc.scad +++ b/testdata/scad/dxf/arc.scad @@ -1 +1,2 @@ import("../../dxf/arc.dxf"); +translate([110,0]) import("../../dxf/arc.dxf", $fn=0.1); diff --git a/testdata/scad/dxf/circle.scad b/testdata/scad/dxf/circle.scad index 8b5d132..edb9f77 100644 --- a/testdata/scad/dxf/circle.scad +++ b/testdata/scad/dxf/circle.scad @@ -1 +1,2 @@ import("../../dxf/circle.dxf"); +translate([210,0,0]) import("../../dxf/circle.dxf", $fn=0.1); diff --git a/testdata/scad/features/circle-tests.scad b/testdata/scad/features/circle-tests.scad index 6b54d55..90cd9f6 100644 --- a/testdata/scad/features/circle-tests.scad +++ b/testdata/scad/features/circle-tests.scad @@ -8,3 +8,4 @@ translate([6,-3,0]) circle(1, $fn=12); translate([0,-6,0]) circle(1, $fa=20, $fs=0.3); translate([3,-6,0]) circle(1, $fa=30, $fs=0.3); translate([6,-6,0]) circle(1, $fa=40, $fs=0.3); +translate([3,-9,0]) circle(1, $fn=0.1); diff --git a/testdata/scad/features/cylinder-tests.scad b/testdata/scad/features/cylinder-tests.scad index 71f43a6..75b06f2 100644 --- a/testdata/scad/features/cylinder-tests.scad +++ b/testdata/scad/features/cylinder-tests.scad @@ -16,5 +16,5 @@ translate([22,11,0]) cylinder(h=15, r=5, r2=5); // tend to "abuse" this for captured nut slots translate([-10,0,0]) cylinder(h=2, r=3, $fn=6); - -// FIXME: We could test $fs, $fa, $fn as well +// Test that we clamp number of sections to a minimum of 3 +translate([-10, -10, 0]) cylinder(r=3.5356, h=7.0711, $fn=0.1, center=true); diff --git a/testdata/scad/features/linear_extrude-tests.scad b/testdata/scad/features/linear_extrude-tests.scad index 528eea2..680bf53 100644 --- a/testdata/scad/features/linear_extrude-tests.scad +++ b/testdata/scad/features/linear_extrude-tests.scad @@ -22,3 +22,6 @@ translate([-15,20,0]) linear_extrude(height=20, scale=[4,5,6]) square(10); translate([-10,5,0]) linear_extrude(height=15, scale=-2) square(10, center=true); // scale given as undefined translate([-15,-15,0]) linear_extrude(height=10, scale=var_undef) square(10); + +// height is negative +translate([0,-25,0]) linear_extrude(-1) square(10, center=true); diff --git a/testdata/scad/features/rotate_extrude-tests.scad b/testdata/scad/features/rotate_extrude-tests.scad index 347bc78..010b7d2 100644 --- a/testdata/scad/features/rotate_extrude-tests.scad +++ b/testdata/scad/features/rotate_extrude-tests.scad @@ -28,3 +28,7 @@ translate([50,50,0]) { translate([-50,0,0]) cube([100,100,100], center=true); } } + +// Minimal $fn +translate([0,-60,0]) rotate_extrude($fn=1) translate([20,0,0]) circle(r=10,$fn=1); + diff --git a/testdata/scad/features/sphere-tests.scad b/testdata/scad/features/sphere-tests.scad index e666c1b..cc80738 100644 --- a/testdata/scad/features/sphere-tests.scad +++ b/testdata/scad/features/sphere-tests.scad @@ -8,3 +8,4 @@ translate([11,11,0]) sphere(5, $fn=15); translate([22,-11, 0]) sphere(5, $fa=20, $fs=0.3); translate([22, 0, 0]) sphere(5, $fa=30, $fs=0.3); translate([22, 11, 0]) sphere(5, $fa=40, $fs=0.3); +translate([11, 22, 0]) sphere(5, $fn=0.1); diff --git a/testdata/scad/misc/value-reassignment-tests.scad b/testdata/scad/misc/value-reassignment-tests.scad index 475f78f..26afa03 100644 --- a/testdata/scad/misc/value-reassignment-tests.scad +++ b/testdata/scad/misc/value-reassignment-tests.scad @@ -1,4 +1,9 @@ +// Test reassignment which depends on a previously assigned variable, +// as this could be messed up if order of assignment evaluation +// changes + myval = 2; i = 2; -myval = i * 2; -echo(myval); +myval = i * 2; // This is not (yet) allowed as it will be evaluates in place of the first assignment +echo(myval, i); // Should output undef, 2 + diff --git a/testdata/scad/misc/value-reassignment-tests2.scad b/testdata/scad/misc/value-reassignment-tests2.scad new file mode 100644 index 0000000..29a2fb7 --- /dev/null +++ b/testdata/scad/misc/value-reassignment-tests2.scad @@ -0,0 +1,16 @@ +// Test reassignment where another variable has used the previous +// value before the reassignment. This could get messed up if order of +// assignment evaluation changes + +myval = 2; +i = myval; +myval = 3; +echo(myval, i); // Should output 3, 3 + +// NB! This feels wrong, but it's a simulation of what happens +// when overriding a variable on the cmd-line: openscad -Dmyval=3 myfile.scad +// Since the intention is to override a top-level variable, the evaluation of the +// new expression must be done in the same place as the old. +// This is currently solved by appending the text given to the -D parameter to the end +// of the main file. + diff --git a/testdata/scad/misc/variable-scope-tests.scad b/testdata/scad/misc/variable-scope-tests.scad index 8426fbb..104d1a4 100644 --- a/testdata/scad/misc/variable-scope-tests.scad +++ b/testdata/scad/misc/variable-scope-tests.scad @@ -49,5 +49,16 @@ echo("undeclared variable can still be passed and used"); module undeclared_var() { echo(d); } - undeclared_var(d=6); + +echo("attempt to assign from a not-yet-defined variable which also exists globally"); + +globalval = 1; +// Test that b = a turns into b = 1, heeding the order of the assignments +// See issue #399 for more discussion +module global_lookup() { + b = globalval; // Should be assigned 1 since the local one isn't yet defined + globalval = 5; // Overrides the value for the local scope only + echo(globalval,b); // Should output 5, 1 +} +global_lookup(); |