(load "Test.carp") (load "Vector.carp") (load "Geometry.carp") (use-all Test Vector3 Geometry Double) (deftest test (assert-equal test &(init 0.0 0.0 0.0) &(Vector3.zero) "zero works") (assert-equal test &(init 1.0 2.0 3.0) &(init 1.0 2.0 3.0) "= operator works") (assert-op test &(init 1.0 2.0 3.0) &(init 1.0 1.0 3.0) "/= operator works" Vector3./=) (assert-op test &(init 1.0 2.0 3.0) &(init 1.000001 2.000001 3.000001) "approx works" vapprox) (assert-equal test &(init 3.0 3.0 4.5) &(add &(init 2.0 1.0 2.0) &(init 1.0 2.0 2.5)) "add operator works") (assert-equal test &(init 1.0 -1.0 -1.5) &(sub &(init 2.0 1.0 2.0) &(init 1.0 2.0 3.5)) "sub operator works") (assert-equal test &(init 4.0 2.0 2.2) &(mul &(init 2.0 1.0 1.1) 2.0) "mul operator works") (assert-equal test &(init 4.0f 2.0f 2.2f) &(mul &(init 2.0f 1.0f 1.1f) 2.0f) "float mul operator works") (assert-equal test &(init 1.0 0.5 0.25) &(div &(init 2.0 1.0 0.5) 2.0) "div operator works") (assert-equal test 5.0 (mag &(init 3.0 4.0 0.0)) "mag works") (assert-equal test 101.0 (mag-sq &(init 10.0 1.0 0.0)) "mag-sq works") (assert-equal test &(init 0.6 0.8 0.0) &(normalize &(init 3.0 4.0 0.0)) "normalize works") (assert-op test 90.0 (radians-to-degree (angle-between &(init 1.0 0.0 0.0) &(init 0.0 1.0 0.0))) "angle-between works" Double.approx) (assert-true test (anti-parallel? &(init 1.0 0.0 0.0) &(init -1.0 0.0 0.0)) "anti-parallel? works") (assert-true test (parallel? &(init 1.0 0.0 0.0) &(init 1.0 0.0 0.0)) "parallel? works") (assert-true test (perpendicular? &(init 1.0 0.0 0.0) &(init 0.0 1.0 0.0)) "perpendicular? works") (assert-equal test 53.0 (dot &(init 10.0 2.0 3.0) &(init 2.0 12.0 3.0)) "dot works") (assert-equal test &(init 2.5 5.0 1.0) &(vlerp &(Vector3.zero) &(init 5.0 10.0 2.0) 0.5) "vlerp works") )