34 lines
849 B
Common Lisp
34 lines
849 B
Common Lisp
;;;; decons/test-decons - basic tests.
|
|
|
|
(defpackage :test-decons
|
|
(:use :common-lisp)
|
|
(:local-nicknames (:t :scopes/testing))
|
|
(:export #:run)
|
|
(:import-from :scopes/testing #:deftest #:== #:!=))
|
|
|
|
(in-package :test-decons)
|
|
|
|
(defun run ()
|
|
(let ((t:*test-suite* (t:test-suite "decons")))
|
|
(test-basic)
|
|
(test-line)
|
|
(t:show-result)))
|
|
|
|
(deftest test-basic ()
|
|
(== decons:*pi* 3.14159)
|
|
(let ((c (make-instance 'decons:circle :radius 2.0)))
|
|
(== (decons:area c) 12.56636))
|
|
(== (funcall (decons:double #'1+) 7) 16)
|
|
(== (decons:absv 7) 7)
|
|
(== (decons:absv -7) 7)
|
|
(== (decons:remainder 7 4) 3)
|
|
)
|
|
|
|
(deftest test-line ()
|
|
(let ((p1 (decons:line 0.0))
|
|
(p2 (decons:line 1.0))
|
|
(ds1 '((2.0 1.0 4.0 3.0)
|
|
(1.8 1.2 4.2 3.3))))
|
|
(== (funcall p1 '(0.5 2.0)) 2.0)
|
|
(== (funcall p2 '(0.5 2.0)) 2.5)
|
|
))
|