mirror of
https://github.com/carp-lang/Carp.git
synced 2024-11-05 18:21:40 +03:00
101 lines
3.0 KiB
Plaintext
101 lines
3.0 KiB
Plaintext
(load "Test.carp")
|
|
(load "Vector.carp")
|
|
(load "Geometry.carp")
|
|
|
|
(use Test)
|
|
(use Vector2)
|
|
(use Geometry)
|
|
|
|
(defn main []
|
|
(with-test test
|
|
(assert-equal test
|
|
&(init 1.0 2.0) &(init 1.0 2.0)
|
|
"= operator works"
|
|
=
|
|
Vector2.str)
|
|
(assert-equal test
|
|
&(init 1.0 2.0) &(init 1.0 1.0)
|
|
"/= operator works"
|
|
/=
|
|
Vector2.str)
|
|
(assert-equal test
|
|
&(init 3.0 3.0)
|
|
&(+ &(init 2.0 1.0) &(init 1.0 2.0))
|
|
"+ operator works"
|
|
=
|
|
Vector2.str)
|
|
(assert-equal test
|
|
&(init 1.0 -1.0)
|
|
&(- &(init 2.0 1.0) &(init 1.0 2.0))
|
|
"- operator works"
|
|
=
|
|
Vector2.str)
|
|
(assert-equal test
|
|
&(init 4.0 2.0)
|
|
&(* &(init 2.0 1.0) 2.0)
|
|
"* operator works"
|
|
=
|
|
Vector2.str)
|
|
(assert-equal test
|
|
&(init 1.0 0.5)
|
|
&(/ &(init 2.0 1.0) 2.0)
|
|
"/ operator works"
|
|
=
|
|
Vector2.str)
|
|
(assert-equal test
|
|
5.0
|
|
(mag &(init 3.0 4.0))
|
|
"mag works"
|
|
Double.=
|
|
Double.str)
|
|
(assert-equal test
|
|
101.0
|
|
(mag-sq &(init 10.0 1.0))
|
|
"mag-sq works"
|
|
Double.=
|
|
Double.str)
|
|
(assert-equal test
|
|
&(init 0.6 0.8)
|
|
&(normalize &(init 3.0 4.0))
|
|
"normalize works"
|
|
Vector2.=
|
|
Vector2.str)
|
|
(assert-equal test
|
|
5.0
|
|
(dist &(init 10.0 10.0) &(init 7.0 6.0))
|
|
"dist works"
|
|
Double.=
|
|
Double.str)
|
|
(assert-equal test
|
|
0.0
|
|
(heading &(init 1.0 0.0))
|
|
"heading works"
|
|
Double.=
|
|
Double.str)
|
|
(assert-equal test
|
|
&(init -2.0 1.0)
|
|
&(rotate &(init 1.0 2.0) (degree-to-radians 90.0))
|
|
"rotate works"
|
|
Vector2.approx
|
|
Vector2.str)
|
|
(assert-equal test
|
|
90.0
|
|
(radians-to-degree (Vector2.angle-between &(init 1.0 0.0) &(init 0.0 1.0)))
|
|
"angle-between works"
|
|
Double.approx
|
|
Double.str)
|
|
(assert-equal test
|
|
44.0
|
|
(dot &(init 10.0 2.0) &(init 2.0 12.0))
|
|
"dot works"
|
|
Double.=
|
|
Double.str)
|
|
(assert-equal test
|
|
&(init 2.5 5.0)
|
|
&(lerp &(init 0.0 0.0) &(init 5.0 10.0) 0.5)
|
|
"lerp works"
|
|
=
|
|
Vector2.str)
|
|
(print-test-results test)
|
|
))
|