From 83ed86cfaaef8e0aa6820b536743fa0289473f70 Mon Sep 17 00:00:00 2001 From: Elmom Date: Thu, 26 Aug 2010 14:19:49 +0300 Subject: [PATCH] Testing improvements and cleanup --- screw.scad | 2 +- servos.scad | 4 ++-- test_compile.py | 11 +++++------ utilities.scad | 31 +++++-------------------------- 4 files changed, 13 insertions(+), 35 deletions(-) diff --git a/screw.scad b/screw.scad index e8598af..cd4ce2b 100644 --- a/screw.scad +++ b/screw.scad @@ -1,5 +1,5 @@ // Parametric screw-like things (ball screws, augers) -// License: GNU GPL 2.0 or later. +// License: GNU LGPL 2.1 or later. // © 2010 by Elmo Mäntynen include diff --git a/servos.scad b/servos.scad index a635a97..b751835 100644 --- a/servos.scad +++ b/servos.scad @@ -104,5 +104,5 @@ module alignds420(position, rotation, screws = 0, axle_lenght = 0) } } -// Example, uncomment to test -alignds420(screws=1); +// Tests: +module test_alignds420(){alignds420(screws=1);} diff --git a/test_compile.py b/test_compile.py index a50e582..b29b82a 100644 --- a/test_compile.py +++ b/test_compile.py @@ -16,14 +16,14 @@ def pytest_generate_tests(metafunc): metafunc.addcall(funcargs=dict(modpath=fpath)) -def test_compile(modname, modpath): - tempname = "test_" + modpath.basename + modname + '.scad' +def test_module_compile(modname, modpath): + tempname = modpath.basename + '-' + modname + '.scad' fpath = temppath.join(tempname) stlpath = temppath.join(tempname + ".stl") f = fpath.open('w') f.write(""" //generated testfile -include <%s> +use <%s> %s(); """ % (modpath, modname)) @@ -34,9 +34,8 @@ include <%s> assert "warning" or "error" not in output[2].strip().lowercase() assert len(stlpath.readlines()) > 2 -def test_compile_default(modpath): - tempname = "test_" + modpath.basename - stlpath = temppath.join(tempname + ".stl") +def test_file_compile(modpath): + stlpath = temppath.join(modpath.basename + "-test.stl") output = call_openscad(path=modpath, stlpath=stlpath) print output assert output[0] is 0 diff --git a/utilities.scad b/utilities.scad index 4eb0643..cafb6ec 100644 --- a/utilities.scad +++ b/utilities.scad @@ -1,14 +1,14 @@ /* * Utility functions. - * + * * Originally by Hans Häggström, 2010. * Dual licenced under Creative Commons Attribution-Share Alike 3.0 and LGPL2 or later */ -function distance(a, b) = sqrt( (a[0] - b[0])*(a[0] - b[0]) + - (a[1] - b[1])*(a[1] - b[1]) + +function distance(a, b) = sqrt( (a[0] - b[0])*(a[0] - b[0]) + + (a[1] - b[1])*(a[1] - b[1]) + (a[2] - b[2])*(a[2] - b[2]) ); function length2(a) = sqrt( a[0]*a[0] + a[1]*a[1] ); @@ -23,27 +23,6 @@ function angle(v) = angleOfNormalizedVector(normalized(v)); function angleBetweenTwoPoints(a, b) = angle(normalized(b-a)); -// Untested -module intersection(big_number=1000000000){ - difference(){ - child(0); - difference(){ - cube(big_number, center=true); - child(1); - } - } -} - -module intersection2(){ - difference(){ - child(0); - difference(){ - child(0); - child(1); - } - } -} - CENTER = 0; LEFT = -0.5; @@ -66,9 +45,9 @@ module fromTo(from=[0,0,0], to=[1*m,0,0], size=[1*cm, 1*cm], align=[CENTER, CENT color(material) translate(from) - rotate(angle) + rotate(angle) translate( [ -endCaps[0]*size[0] - endExtras[0], size[0]*(-0.5-align[0]), size[1]*(-0.5+align[1]) ] ) - rotate(rotation) + rotate(rotation) scale([length, size[0], size[1]]) child(); } }