1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-11 09:14:29 +02:00

added modules to avoid namespace problems

This commit is contained in:
Justin Lin
2017-06-22 18:17:02 +08:00
parent 40e4ba5b12
commit 9d770c9cf8
7 changed files with 198 additions and 175 deletions

View File

@@ -21,12 +21,14 @@ include <test_bend.scad>;
// Function
include <test_rotate_p.scad>;
include <test_paths2sections.scad>;
include <test_sub_str.scad>;
include <test_split_str.scad>;
include <test_parse_number.scad>;
include <test_cross_sections.scad>;
include <test_paths2sections.scad>;
// Path
include <test_circle_path.scad>;
// 2D Shape
include <test_shape_arc.scad>;

View File

@@ -1,11 +1,8 @@
include <unittest.scad>;
include <bend.scad>;
module test_bend() {
include <unittest.scad>;
include <bend.scad>;
x = 9.25;
y = 9.55;
z = 1;
module test_bend_tri_frag(points, angle) {
module test_bend_tri_frag(points, angle) {
echo("==== test_bend_tri_frag ====");
expected_points = [[0, 0], [0.1927, 1.9566], [0.3854, 0], [0, 0]];
@@ -13,7 +10,10 @@ module test_bend_tri_frag(points, angle) {
assertEqualPoints(expected_points, points);
assertEqual(expected_angle, angle);
}
bend(size = [x, y, z], angle = 270)
linear_extrude(z) text("A");
}
bend(size = [x, y, z], angle = 270)
linear_extrude(z) text("A");
test_bend();

View File

@@ -1,31 +1,32 @@
echo("==== test_cross_sections ====");
module test_cross_sections() {
echo("==== test_cross_sections ====");
include <unittest.scad>;
include <polysections.scad>;
include <cross_sections.scad>;
include <archimedean_spiral.scad>;
include <rotate_p.scad>;
include <unittest.scad>;
include <polysections.scad>;
include <cross_sections.scad>;
include <archimedean_spiral.scad>;
include <rotate_p.scad>;
shape_pts = [
shape_pts = [
[-2, -10],
[-2, 10],
[2, 10],
[2, -10]
];
];
pts_angles = archimedean_spiral(
pts_angles = archimedean_spiral(
arm_distance = 20,
init_angle = 180,
point_distance = 5,
num_of_points = 100
);
);
pts = [for(pt_angle = pts_angles) pt_angle[0]];
angles = [
pts = [for(pt_angle = pts_angles) pt_angle[0]];
angles = [
for(i = [0:len(pts_angles) - 1]) [90, 0, pts_angles[i][1]]
];
];
expected = [
expected = [
[[-8, 0, -10], [-8, 0, 10], [-12, 0, 10], [-12, 0, -10]]
,[[-8.6994, -4.8132, -9.967], [-8.1492, -4.5088, 9.8412], [-11.6157, -6.4267, 9.967], [-12.1659, -6.7311, -9.8412]]
,[[-6.878, -9.4072, -9.923], [-6.143, -8.4019, 9.6739], [-8.4562, -11.5658, 9.923], [-9.1913, -12.5711, -9.6739]]
@@ -126,10 +127,13 @@ expected = [
,[[29.6956, -48.7161, 1.1644], [29.6176, -48.5881, -1.1944], [29.372, -48.1852, -1.1644], [29.4501, -48.3133, 1.1944]]
,[[34.0009, -46.0918, 1.0834], [33.9598, -46.0361, -1.0973], [33.7009, -45.6851, -1.0834], [33.742, -45.7408, 1.0973]]
,[[38.0578, -43.1059, 1], [38.0578, -43.1059, -1], [37.793, -42.8061, -1], [37.793, -42.8061, 1]]
];
];
sects = cross_sections(shape_pts, pts, angles, twist = 180, scale = 0.1);
sects = cross_sections(shape_pts, pts, angles, twist = 180, scale = 0.1);
for(i = [0:len(expected) - 1]) {
for(i = [0:len(expected) - 1]) {
assertEqualPoints(expected[i], sects[i]);
}
}
test_cross_sections();

View File

@@ -1,9 +1,13 @@
echo("==== test_parse_number ====");
module test_parse_number() {
echo("==== test_parse_number ====");
include <unittest.scad>;
include <sub_str.scad>;
include <split_str.scad>;
include <parse_number.scad>;
include <unittest.scad>;
include <sub_str.scad>;
include <split_str.scad>;
include <parse_number.scad>;
assertEqual(11, parse_number("10") + 1);
assertEqual(-0.1, parse_number("-1.1") + 1);
assertEqual(11, parse_number("10") + 1);
assertEqual(-0.1, parse_number("-1.1") + 1);
}
test_parse_number();

File diff suppressed because one or more lines are too long

View File

@@ -1,7 +1,11 @@
echo("==== test_split_str ====");
module test_split_str() {
echo("==== test_split_str ====");
include <unittest.scad>;
include <sub_str.scad>;
include <split_str.scad>;
include <unittest.scad>;
include <sub_str.scad>;
include <split_str.scad>;
assertEqual(["hello", "world"], split_str("hello,world", ","));
assertEqual(["hello", "world"], split_str("hello,world", ","));
}
test_split_str();

View File

@@ -1,7 +1,11 @@
echo("==== test_sub_str ====");
module test_sub_str() {
echo("==== test_sub_str ====");
include <unittest.scad>;
include <sub_str.scad>;
include <unittest.scad>;
include <sub_str.scad>;
assertEqual("hello", sub_str("helloworld", 0, 5));
assertEqual("world", sub_str("helloworld", 5));
assertEqual("hello", sub_str("helloworld", 0, 5));
assertEqual("world", sub_str("helloworld", 5));
}
test_sub_str();