mirror of
https://github.com/revarbat/BOSL2.git
synced 2025-08-13 20:44:20 +02:00
Regression test fixes.
This commit is contained in:
@@ -3,8 +3,7 @@
|
||||
OPENSCAD=/Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD
|
||||
|
||||
for testscript in tests/test_*.scad ; do
|
||||
echo -n "$testscript: "
|
||||
${OPENSCAD} -o .off --hardwarnings --check-parameters true --check-parameter-ranges true $testscript >>/dev/null 2>&1
|
||||
[ $? != 0 ] && echo "PASS" || echo "FAIL!"
|
||||
repname="$(basename $testscript|sed 's/^test_//')"
|
||||
${OPENSCAD} -o .off --hardwarnings --check-parameters true --check-parameter-ranges true $testscript 2>&1 && echo "$repname: PASS" || echo -e "$repname: FAIL!\n"
|
||||
done
|
||||
|
||||
|
@@ -49,7 +49,6 @@ module test_list_range() {
|
||||
assert(list_range(4) == [0,1,2,3]);
|
||||
assert(list_range(n=4, step=2) == [0,2,4,6]);
|
||||
assert(list_range(n=4, s=3, step=3) == [3,6,9,12]);
|
||||
assert(list_range(n=4, s=3, e=9, step=3) == [3,6,9]);
|
||||
assert(list_range(e=3) == [0,1,2,3]);
|
||||
assert(list_range(e=6, step=2) == [0,2,4,6]);
|
||||
assert(list_range(s=3, e=5) == [3,4,5]);
|
||||
@@ -70,7 +69,7 @@ module test_deduplicate() {
|
||||
assert(deduplicate([8,3,4,4,4,8,2,3,3,8,8]) == [8,3,4,8,2,3,8]);
|
||||
assert(deduplicate(closed=true, [8,3,4,4,4,8,2,3,3,8,8]) == [8,3,4,8,2,3]);
|
||||
assert(deduplicate("Hello") == ["H","e","l","o"]);
|
||||
assert(deduplicate([[3,4],[7,2],[7,1.99],[1,4]],eps=0.1) == [[3,4],[7,2],[1,4]]);
|
||||
assert(deduplicate([[3,4],[7,1.99],[7,2],[1,4]],eps=0.1) == [[3,4],[7,2],[1,4]]);
|
||||
}
|
||||
test_deduplicate();
|
||||
|
||||
@@ -83,8 +82,8 @@ test_list_set();
|
||||
|
||||
|
||||
module test_list_remove() {
|
||||
assert(list_insert([3,6,9,12],1) == [3,9,12]);
|
||||
assert(list_insert([3,6,9,12],[1,3]) == [3,9]);
|
||||
assert(list_remove([3,6,9,12],1) == [3,9,12]);
|
||||
assert(list_remove([3,6,9,12],[1,3]) == [3,9]);
|
||||
}
|
||||
test_list_remove();
|
||||
|
||||
@@ -315,5 +314,7 @@ module test_transpose() {
|
||||
test_transpose();
|
||||
|
||||
|
||||
cube();
|
||||
|
||||
|
||||
// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
|
||||
|
@@ -31,10 +31,29 @@ module test_path3d() {
|
||||
test_path3d();
|
||||
|
||||
|
||||
module test_point4d() {
|
||||
assert(point4d([1,2,3,4,5])==[1,2,3,4]);
|
||||
assert(point4d([1,2,3,4])==[1,2,3,4]);
|
||||
assert(point4d([1,2,3])==[1,2,3,0]);
|
||||
assert(point4d([2,3])==[2,3,0,0]);
|
||||
assert(point4d([1])==[1,0,0,0]);
|
||||
}
|
||||
test_point4d();
|
||||
|
||||
|
||||
module test_path4d() {
|
||||
assert(path4d([[1], [1,2], [1,2,3], [1,2,3,4], [1,2,3,4,5]])==[[1,0,0,0],[1,2,0,0],[1,2,3,0],[1,2,3,4],[1,2,3,4]]);
|
||||
}
|
||||
test_path4d();
|
||||
|
||||
|
||||
module test_translate_points() {
|
||||
pts = [[0,0,1], [0,1,0], [1,0,0], [0,0,-1], [0,-1,0], [-1,0,0]];
|
||||
assert(translate_points(pts, v=[1,2,3]) == [[1,2,4], [1,3,3], [2,2,3], [1,2,2], [1,1,3], [0,2,3]]);
|
||||
assert(translate_points(pts, v=[-1,-2,-3]) == [[-1,-2,-2], [-1,-1,-3], [0,-2,-3], [-1,-2,-4], [-1,-3,-3], [-2,-2,-3]]);
|
||||
assert(translate_points(pts, v=[1,2]) == [[1,2,1], [1,3,0], [2,2,0], [1,2,-1], [1,1,0], [0,2,0]]);
|
||||
pts2 = [[0,1], [1,0], [0,-1], [-1,0]];
|
||||
assert(translate_points(pts2, v=[1,2]) == [[1,3], [2,2], [1,1], [0,2]]);
|
||||
}
|
||||
test_translate_points();
|
||||
|
||||
@@ -45,6 +64,8 @@ module test_scale_points() {
|
||||
assert(scale_points(pts, v=[-2,-3,-4]) == [[0,0,-4], [0,-3,0], [-2,0,0], [0,0,4], [0,3,0], [2,0,0]]);
|
||||
assert(scale_points(pts, v=[1,1,1]) == [[0,0,1], [0,1,0], [1,0,0], [0,0,-1], [0,-1,0], [-1,0,0]]);
|
||||
assert(scale_points(pts, v=[-1,-1,-1]) == [[0,0,-1], [0,-1,0], [-1,0,0], [0,0,1], [0,1,0], [1,0,0]]);
|
||||
pts2 = [[0,1], [1,0], [0,-1], [-1,0]];
|
||||
assert(scale_points(pts2, v=[2,3]) == [[0,3], [2,0], [0,-3], [-2,0]]);
|
||||
}
|
||||
test_scale_points();
|
||||
|
||||
@@ -76,21 +97,31 @@ module test_rotate_points3d() {
|
||||
test_rotate_points3d();
|
||||
|
||||
|
||||
module test_simplify_path()
|
||||
{
|
||||
path = [[-20,10],[-10,0],[-5,0],[0,0],[5,0],[10,0], [10,10]];
|
||||
assert(simplify_path(path) == [[-20,10],[-10,0],[10,0], [10,10]]);
|
||||
module test_polar_to_xy() {
|
||||
assert(approx(polar_to_xy(20,45), [20/sqrt(2), 20/sqrt(2)]));
|
||||
assert(approx(polar_to_xy(20,135), [-20/sqrt(2), 20/sqrt(2)]));
|
||||
assert(approx(polar_to_xy(20,-135), [-20/sqrt(2), -20/sqrt(2)]));
|
||||
assert(approx(polar_to_xy(20,-45), [20/sqrt(2), -20/sqrt(2)]));
|
||||
assert(approx(polar_to_xy(40,30), [40*sqrt(3)/2, 40/2]));
|
||||
assert(approx(polar_to_xy([40,30]), [40*sqrt(3)/2, 40/2]));
|
||||
}
|
||||
test_simplify_path();
|
||||
test_polar_to_xy();
|
||||
|
||||
|
||||
module test_simplify_path_indexed()
|
||||
{
|
||||
points = [[-20,10],[-10,0],[-5,0],[0,0],[5,0],[10,0], [10,10]];
|
||||
path = list_range(len(points));
|
||||
assert(simplify_path_indexed(points, path) == [0,1,5,6]);
|
||||
module test_xy_to_polar() {
|
||||
assert(approx(xy_to_polar([20/sqrt(2), 20/sqrt(2)]),[20,45]));
|
||||
assert(approx(xy_to_polar([-20/sqrt(2), 20/sqrt(2)]),[20,135]));
|
||||
assert(approx(xy_to_polar([-20/sqrt(2), -20/sqrt(2)]),[20,-135]));
|
||||
assert(approx(xy_to_polar([20/sqrt(2), -20/sqrt(2)]),[20,-45]));
|
||||
assert(approx(xy_to_polar([40*sqrt(3)/2, 40/2]),[40,30]));
|
||||
assert(approx(xy_to_polar([-40*sqrt(3)/2, 40/2]),[40,150]));
|
||||
assert(approx(xy_to_polar([-40*sqrt(3)/2, -40/2]),[40,-150]));
|
||||
assert(approx(xy_to_polar([40*sqrt(3)/2, -40/2]),[40,-30]));
|
||||
}
|
||||
test_simplify_path_indexed();
|
||||
test_xy_to_polar();
|
||||
|
||||
|
||||
cube();
|
||||
|
||||
|
||||
// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
|
||||
|
@@ -40,14 +40,6 @@ module test_point_left_of_segment() {
|
||||
test_point_left_of_segment();
|
||||
|
||||
|
||||
module test_right_of_line2d() {
|
||||
assert(right_of_line2d([[-10,-10], [10,10]], [ -3, 0]) == false);
|
||||
assert(right_of_line2d([[-10,-10], [10,10]], [ 0, 0]) == false);
|
||||
assert(right_of_line2d([[-10,-10], [10,10]], [ 3, 0]) == true);
|
||||
}
|
||||
test_right_of_line2d();
|
||||
|
||||
|
||||
module test_collinear() {
|
||||
assert(collinear([-10,-10], [-15, -16], [10,10]) == false);
|
||||
assert(collinear([-10,-10], [-15, -15], [10,10]) == true);
|
||||
@@ -84,12 +76,12 @@ module test_distance_from_line() {
|
||||
test_distance_from_line();
|
||||
|
||||
|
||||
module test_triangle_area2d() {
|
||||
assert(abs(triangle_area2d([0,0], [0,10], [10,0]) + 50) < EPSILON);
|
||||
assert(abs(triangle_area2d([0,0], [0,10], [0,15])) < EPSILON);
|
||||
assert(abs(triangle_area2d([0,0], [10,0], [0,10]) - 50) < EPSILON);
|
||||
module test_triangle_area() {
|
||||
assert(abs(triangle_area([0,0], [0,10], [10,0]) + 50) < EPSILON);
|
||||
assert(abs(triangle_area([0,0], [0,10], [0,15])) < EPSILON);
|
||||
assert(abs(triangle_area([0,0], [10,0], [0,10]) - 50) < EPSILON);
|
||||
}
|
||||
test_triangle_area2d();
|
||||
test_triangle_area();
|
||||
|
||||
|
||||
module test_plane3pt() {
|
||||
@@ -198,5 +190,7 @@ module test_pointlist_bounds() {
|
||||
test_pointlist_bounds();
|
||||
|
||||
|
||||
cube();
|
||||
|
||||
|
||||
// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
|
||||
|
@@ -13,9 +13,9 @@ module test_quant() {
|
||||
assert(quant(3,3) == 3);
|
||||
assert(quant(4,3) == 3);
|
||||
assert(quant(7,3) == 6);
|
||||
assert(quant([12,13,13.1,14,14.1,15,16],4) == [12,12,12,16,16,16,16])
|
||||
assert(quant([9,10,10.4,10.5,11,12],3) == [9,9,9,12,12,12])
|
||||
assert(quant([[9,10,10.4],[10.5,11,12]],3) == [[9,9,9],[12,12,12]])
|
||||
assert(quant([12,13,13.1,14,14.1,15,16],4) == [12,12,12,16,16,16,16]);
|
||||
assert(quant([9,10,10.4,10.5,11,12],3) == [9,9,9,12,12,12]);
|
||||
assert(quant([[9,10,10.4],[10.5,11,12]],3) == [[9,9,9],[12,12,12]]);
|
||||
}
|
||||
test_quant();
|
||||
|
||||
@@ -31,9 +31,9 @@ module test_quantdn() {
|
||||
assert(quantdn(3,3) == 3);
|
||||
assert(quantdn(4,3) == 3);
|
||||
assert(quantdn(7,3) == 6);
|
||||
assert(quantdn([12,13,13.1,14,14.1,15,16],4) == [12,12,12,12,12,12,16])
|
||||
assert(quantdn([9,10,10.4,10.5,11,12],3) == [9,9,9,9,9,12])
|
||||
assert(quantdn([[9,10,10.4],[10.5,11,12]],3) == [[9,9,9],[9,9,12]])
|
||||
assert(quantdn([12,13,13.1,14,14.1,15,16],4) == [12,12,12,12,12,12,16]);
|
||||
assert(quantdn([9,10,10.4,10.5,11,12],3) == [9,9,9,9,9,12]);
|
||||
assert(quantdn([[9,10,10.4],[10.5,11,12]],3) == [[9,9,9],[9,9,12]]);
|
||||
}
|
||||
test_quantdn();
|
||||
|
||||
@@ -49,9 +49,9 @@ module test_quantup() {
|
||||
assert(quantup(3,3) == 3);
|
||||
assert(quantup(4,3) == 6);
|
||||
assert(quantup(7,3) == 9);
|
||||
assert(quantup([12,13,13.1,14,14.1,15,16],4) == [12,16,16,16,16,16,16])
|
||||
assert(quantup([9,10,10.4,10.5,11,12],3) == [9,12,12,12,12,12])
|
||||
assert(quantup([[9,10,10.4],[10.5,11,12]],3) == [[9,12,12],[12,12,12]])
|
||||
assert(quantup([12,13,13.1,14,14.1,15,16],4) == [12,16,16,16,16,16,16]);
|
||||
assert(quantup([9,10,10.4,10.5,11,12],3) == [9,12,12,12,12,12]);
|
||||
assert(quantup([[9,10,10.4],[10.5,11,12]],3) == [[9,12,12],[12,12,12]]);
|
||||
}
|
||||
test_quantup();
|
||||
|
||||
@@ -130,12 +130,12 @@ test_posmod();
|
||||
|
||||
|
||||
module test_modang() {
|
||||
assert(modang(-700,360) == 20)
|
||||
assert(modang(-270,360) == 90)
|
||||
assert(modang(-120,360) == -120)
|
||||
assert(modang(120,360) == 120)
|
||||
assert(modang(270,360) == -90)
|
||||
assert(modang(700,360) == -20)
|
||||
assert(modang(-700) == 20);
|
||||
assert(modang(-270) == 90);
|
||||
assert(modang(-120) == -120);
|
||||
assert(modang(120) == 120);
|
||||
assert(modang(270) == -90);
|
||||
assert(modang(700) == -20);
|
||||
}
|
||||
test_modang();
|
||||
|
||||
@@ -269,8 +269,8 @@ module test_cumsum() {
|
||||
assert(cumsum([1,1,1]) == [1,2,3]);
|
||||
assert(cumsum([2,2,2]) == [2,4,6]);
|
||||
assert(cumsum([1,2,3]) == [1,3,6]);
|
||||
assert(cumsum([-2,-1,0,1,2]) == 0);
|
||||
assert(cumsum([[1,2,3], [3,4,5], [5,6,7]]) == [[1,2,3],[4,6,8],[9,12,15]);
|
||||
assert(cumsum([-2,-1,0,1,2]) == [-2,-3,-3,-2,0]);
|
||||
assert(cumsum([[1,2,3], [3,4,5], [5,6,7]]) == [[1,2,3],[4,6,8],[9,12,15]]);
|
||||
}
|
||||
test_cumsum();
|
||||
|
||||
@@ -477,6 +477,7 @@ module test_count_true() {
|
||||
test_count_true();
|
||||
|
||||
|
||||
cube();
|
||||
|
||||
|
||||
// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
|
||||
|
@@ -17,7 +17,7 @@ module test_add_scalar() {
|
||||
assert(add_scalar([1,2,3],3) == [4,5,6]);
|
||||
assert(add_scalar([[1,2,3],[3,4,5]],3) == [[4,5,6],[6,7,8]]);
|
||||
}
|
||||
test_add_scalar()
|
||||
test_add_scalar();
|
||||
|
||||
|
||||
module test_vmul() {
|
||||
@@ -97,4 +97,7 @@ module test_vector_axis() {
|
||||
test_vector_axis();
|
||||
|
||||
|
||||
cube();
|
||||
|
||||
|
||||
// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
|
||||
|
Reference in New Issue
Block a user