more docs and CHECKMEs
[CommonLispStat.git] / unittests-protoObj.lisp
blob7358b545accf6bfb5c25c1ffbb82083894f436ab
1 ;;; -*- mode: lisp -*-
2 ;;; Copyright (c) 2007, by A.J. Rossini <blindglobe@gmail.com>
3 ;;; See COPYRIGHT file for any additional restrictions (BSD license).
4 ;;; Since 1991, ANSI was finally finished. Edited for ANSI Common Lisp.
6 ;;; This is semi-external to lispstat core packages. The dependency
7 ;;; should be that lispstat packages are dependencies for the unit
8 ;;; tests. However, where they will end up is still to be
9 ;;; determined.
11 (in-package :cl-user)
13 (defpackage :lisp-stat-unittests-proto
14 (:use :common-lisp :lift :lisp-stat-object-system)
15 (:export run-lisp-stat-proto-tests run-lisp-stat-proto-test scoreboard))
17 (in-package :lisp-stat-unittests)
19 ;;; TESTS
21 (defun run-lisp-stat-tests ()
22 (run-tests :suite 'lisp-stat))
24 (defun run-lisp-stat-test (&rest x)
25 (run-test x))
28 (deftestsuite lisp-stat-object-system () ())
29 (deftestsuite lisp-stat-proto-basic (lisp-stat-object-system) ())
30 (deftestsuite lisp-stat-proto-use (lisp-stat-object-system) ())
33 ;; EXAMPLES, not for use
35 #+nil(progn
36 (addtest (lisp-stat-lin-alg) eigen
37 (ensure-same
38 (eigen #2A((2 3 4) (1 2 4) (2 4 5)))
39 (list #(10.656854249492381 -0.6568542494923802 -0.9999999999999996)
40 (list #(0.4999999999999998 0.4999999999999997 0.7071067811865475)
41 #(-0.49999999999999856 -0.5000000000000011 0.7071067811865474)
42 #(0.7071067811865483 -0.7071067811865466 -1.2560739669470215e-15))
43 NIL)))
45 (addtest (lisp-stat-lin-alg) spline
46 (ensure-same
47 (spline #(1.0 1.2 1.3 1.8 2.1 2.5)
48 #(1.2 2.0 2.1 2.0 1.1 2.8)
49 :xvals 6)
50 (list (list 1.0 1.3 1.6 1.9 2.2 2.5)
51 (list 1.2 2.1 2.2750696543866313 1.6465231041904045 1.2186576148879609 2.8))
52 :test 'almost=lists)))
54 ;;;; Object System tests
56 (deftestsuite lisp-stat-proto-use (lisp-stat-object-system)
58 (:documentation "Make sure the proto object system is valid.")
59 (:tests
60 (create-proto (ensure (object-proto-p (defproto test-me))))
61 (create-proto2 (ensure (object-proto-p (defproto2 test-me2))))
62 (instance1 (ensure (send test-me :isnew)))
63 (instance1-2 (ensure (send test-me2 :isnew)))
64 (instance2 (ensure (send test-me :has-slot 'new)))
65 (instance2-2 (ensure (send test-me2 :has-slot 'new)))
67 (instance5 (ensure (send test-me :has-slot 'new)))
68 (instance5-2 (ensure (send test-me2 :has-slot 'new)))
69 (instance5 (ensure (send test-me :own-slots 'new)))
70 (instance5-2 (ensure (send test-me2 :own-slots 'new)))
71 (instance5 (ensure (send test-me :has-slot 'new)))
72 (instance5-2 (ensure (send test-me2 :has-slot 'new)))
73 (instance5 (ensure (send test-me :has-slot 'new)))
74 (instance5-2 (ensure (send test-me2 :has-slot 'new)))