diff options
author | Marius Kintel <marius@kintel.net> | 2013-06-18 05:46:48 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2013-06-18 05:46:48 (GMT) |
commit | 6d91540e4cc3f9fe0caaea63ac64518a5626d28b (patch) | |
tree | ca7034453a1f55124e4b7378aaab22985aff6a21 /testdata | |
parent | 95947a877b8e88521a7f00348d56c89e9b7c2a79 (diff) | |
parent | 6c7d386a3338039416ced323bf1aa75edbb43d19 (diff) |
Merge branch 'master' into epec-kernel
Diffstat (limited to 'testdata')
23 files changed, 234 insertions, 47 deletions
diff --git a/testdata/modulecache-tests/README.txt b/testdata/modulecache-tests/README.txt index 277cff8..214acc5 100644 --- a/testdata/modulecache-tests/README.txt +++ b/testdata/modulecache-tests/README.txt @@ -26,13 +26,6 @@ o Open use-mcad.scad o Compile (F5) o Check that you get a rounded box -Test4: USE Non-existing file ------- - -o Open usenonexsistingfile.scad -o Compile (F5) -o Verify that you get: WARNING: Can't open 'use' file 'nofile.scad'. - Test5: Overload USEd module ------ @@ -72,10 +65,62 @@ o Compile (F5) - Verify that you get a circular disc o Edit radius.scad: Change RADIUS o Compile (F5) - Verify that the disc changed size -Test9: Circular include +Test10: Circular include ------ o Open circularincludemain.scad o Compile (F5) o Verify that OpenSCAD won't hang or crash +Test11: Missing include file appears +------ +o rm missing.scad +o Open includemissing.scad +o Compile (F5) +o Verify that you get: WARNING: Can't open include file 'missing.scad'. +o echo "module missing() { sphere(10); }" > missing.scad +o Reload and Compile (F4) - verify that the sphere appeared +o rm missing.scad +o Reload and Compile (F4) - verify that the sphere is still there +o echo "module missing() { sphere(20); }" > missing.scad +o Reload and Compile (F4) - verify that the sphere increased in size + +Test12: Missing include file in subpath appears +------ +o rm subdir/missingsub.scad +o Open includemissingsub.scad +o Compile (F5) +o Verify that you get: WARNING: Can't open include file 'subdir/missingsub.scad'. +o echo "module missingsub() { sphere(10); }" > subdir/missingsub.scad +o Reload and Compile (F4) - verify that the sphere appeared +o rm subdir/missingsub.scad +o Reload and Compile (F4) - verify that the sphere is still there +o echo "module missingsub() { sphere(20); }" > subdir/missingsub.scad +o Reload and Compile (F4) - verify that the sphere increased in size + +Test13: Missing library file appears +------- +o rm missing.scad +o Open usemissing.scad +o Compile (F5) +o Verify that you get: WARNING: Can't open library file 'missing.scad'. +o echo "module missing() { sphere(10); }" > missing.scad +o Reload and Compile (F4) - verify that the sphere appeared +o rm missing.scad +o Reload and Compile (F4) - verify that the sphere is still there +o echo "module missing() { sphere(20); }" > missing.scad +o Reload and Compile (F4) - verify that the sphere increased in size + +Test14: Automatic reload of cascading changes +------- + +o ./cascade.sh +o Open cascadetest.scad +o Turn on Automatic Reload and Compile +o Verify that the 4 objects render correctly +o rm cascadetest.scad +o Verify that no rerendering was triggered (the 4 objects are still there) +o rm cascade*.scad +o Verify that no rerendering was triggered (the 4 objects are still there) +o ./cascade2.sh +o Verify that everything reloads at once without flickering diff --git a/testdata/modulecache-tests/cascade.sh b/testdata/modulecache-tests/cascade.sh new file mode 100755 index 0000000..3193d06 --- /dev/null +++ b/testdata/modulecache-tests/cascade.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +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 +sleep 0.05 +echo "module B() { cube([8,8,8], center=true); }" > cascade-B.scad +sleep 0.05 +echo "module C() { cylinder(h=8, r=5, center=true); }" > cascade-C.scad +sleep 0.05 +echo "module D() { cylinder(h=10, r1=5, r2=0, center=true); }" > cascade-D.scad diff --git a/testdata/modulecache-tests/cascade2.sh b/testdata/modulecache-tests/cascade2.sh new file mode 100755 index 0000000..4969e6f --- /dev/null +++ b/testdata/modulecache-tests/cascade2.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +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 +sleep 0.1 +echo "module B() { cube([10,10,10], center=true); }" > cascade-B.scad +sleep 0.1 +echo "module C() { cylinder(h=10, r=6, center=true); }" > cascade-C.scad +sleep 0.1 +echo "module D() { cylinder(h=12, r1=6, r2=0, center=true); }" > cascade-D.scad diff --git a/testdata/modulecache-tests/includemissing.scad b/testdata/modulecache-tests/includemissing.scad new file mode 100644 index 0000000..d8a165f --- /dev/null +++ b/testdata/modulecache-tests/includemissing.scad @@ -0,0 +1,2 @@ +include <missing.scad> +missing(); diff --git a/testdata/modulecache-tests/includemissingsub.scad b/testdata/modulecache-tests/includemissingsub.scad new file mode 100644 index 0000000..50acffe --- /dev/null +++ b/testdata/modulecache-tests/includemissingsub.scad @@ -0,0 +1,2 @@ +include <subdir/missingsub.scad> +missingsub(); diff --git a/testdata/modulecache-tests/usemissing.scad b/testdata/modulecache-tests/usemissing.scad new file mode 100644 index 0000000..9f80b8b --- /dev/null +++ b/testdata/modulecache-tests/usemissing.scad @@ -0,0 +1,2 @@ +use <missing.scad> +missing(); 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/background-modifier.scad b/testdata/scad/features/background-modifier.scad index 5430472..d67270e 100644 --- a/testdata/scad/features/background-modifier.scad +++ b/testdata/scad/features/background-modifier.scad @@ -3,3 +3,8 @@ difference() { %cylinder(h=30, r=6, center=true); } %if (true) cube([25,6,3], center=true); + +%translate([0,-9,0]) difference() { + color("green") cube([10,4,10], center=true); + color("red") translate([0,-2,0]) sphere(3); +} 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/highlight-and-background-modifier.scad b/testdata/scad/features/highlight-and-background-modifier.scad index 5dca703..d97408b 100644 --- a/testdata/scad/features/highlight-and-background-modifier.scad +++ b/testdata/scad/features/highlight-and-background-modifier.scad @@ -1,10 +1,31 @@ difference() { sphere(r=10); %#cylinder(h=30, r=6, center=true); - %#if (true) cube([6,25,3], center=true); + %#if (true) cube([25,6,3], center=true); } -translate([13,0,0]) difference() { - sphere(r=10); - #%cylinder(h=30, r=6, center=true); - #%if (true) cube([6,25,3], center=true); +%#translate([0,-9,0]) difference() { + color("green") cube([10,4,10], center=true); + color("red") translate([0,-2,0]) sphere(3); +} +%translate([13,0,0]){ + difference() { + sphere(r=10); + cylinder(h=30, r=6, center=true); + if (true) cube([25,6,3], center=true); + } + #translate([0,-9,0]) difference() { + color("green") cube([10,4,10], center=true); + color("red") translate([0,-2,0]) sphere(3); + } +} +#translate([26,0,0]){ + difference() { + sphere(r=10); + cylinder(h=30, r=6, center=true); + if (true) cube([25,6,3], center=true); + } + %translate([0,-9,0]) difference() { + color("green") cube([10,4,10], center=true); + color("red") translate([0,-2,0]) sphere(3); + } } diff --git a/testdata/scad/features/highlight-modifier.scad b/testdata/scad/features/highlight-modifier.scad index f228d08..2141f58 100644 --- a/testdata/scad/features/highlight-modifier.scad +++ b/testdata/scad/features/highlight-modifier.scad @@ -3,3 +3,8 @@ difference() { #cylinder(h=30, r=6, center=true); } #if (true) cube([25,6,3], center=true); + +#translate([0,-9,0]) difference() { + color("green") cube([10,4,10], center=true); + color("red") translate([0,-2,0]) sphere(3); +} diff --git a/testdata/scad/features/ifelse-tests.scad b/testdata/scad/features/ifelse-tests.scad index d8c777b..3c72d55 100644 --- a/testdata/scad/features/ifelse-tests.scad +++ b/testdata/scad/features/ifelse-tests.scad @@ -1,5 +1,11 @@ -if (true) cube(2, true); -else cylinder(r=1,h=2); +if (true) { + cube(2, true); + translate([-3,0,0]) cube(2, true); +} +else { + cylinder(r=1,h=2); + translate([-3,0,0]) cylinder(r=1,h=2); +} translate([3,0,0]) if (false) cylinder(r=1,h=2); 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/minimal/allexpressions.scad b/testdata/scad/minimal/allexpressions.scad new file mode 100644 index 0000000..f618c4b --- /dev/null +++ b/testdata/scad/minimal/allexpressions.scad @@ -0,0 +1,30 @@ +a = true; +b = false; +c = undef; +d = a; +e = $fn; +f1 = [1,,]; +f2 = [1,2,3]; +g = f2.x + f2.y + f2.z; +h1 = [2:5]; +h2 = [1:2:10]; +i = h2.begin - h2.step - h2.end; +j = "test"; +k = 1.23e-2; +l = a * b; +m = a / b; +n = a % b; +o = c < d; +p = c <= d; +q = c == d; +r = c != d; +s = c >= d; +t = c > d; +u = e && g; +v = e || g; +w = +i; +x = -i; +y = !i; +z = (j); +aa = k ? l : m; +bb = n[o]; diff --git a/testdata/scad/minimal/allfunctions.scad b/testdata/scad/minimal/allfunctions.scad index 2aebe54..b97f121 100644 --- a/testdata/scad/minimal/allfunctions.scad +++ b/testdata/scad/minimal/allfunctions.scad @@ -1,27 +1,28 @@ a = abs(); -a = sign(); -a = rands(); -a = min(); -a = max(); -a = sin(); -a = cos(); -a = asin(); -a = acos(); -a = tan(); -a = atan(); -a = atan2(); -a = round(); -a = ceil(); -a = floor(); -a = pow(); -a = sqrt(); -a = exp(); -a = log(); -a = ln(); -a = str(); -a = lookup(); -a = dxf_dim(); -a = dxf_cross(); -a = version(); -a = version_num(); -a = len(); +b = sign(); +c = rands(); +d = min(); +e = max(); +f = sin(); +g = cos(); +h = asin(); +i = acos(); +j = tan(); +k = atan(); +l = atan2(); +m = round(); +n = ceil(); +o = floor(); +p = pow(); +q = sqrt(); +r = exp(); +s = log(); +t = ln(); +u = str(); +v = lookup(); +w = dxf_dim(); +x = dxf_cross(); +y = version(); +z = version_num(); +aa = len(); +bb = search(); diff --git a/testdata/scad/minimal/allmodules.scad b/testdata/scad/minimal/allmodules.scad index 4395fd7..2e38d8f 100644 --- a/testdata/scad/minimal/allmodules.scad +++ b/testdata/scad/minimal/allmodules.scad @@ -2,12 +2,13 @@ minkowski(); glide(); subdiv(); hull(); +resize(); child(); echo(); assign(); for(); intersection_for(); -if(true) { } +if(false) { cube(); } else { sphere(); } union(); difference(); intersection(); 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(); |