source: project/release/5/protobj/tags/0.5/tests/run.scm @ 37997

Last change on this file since 37997 was 37997, checked in by felix winkelmann, 2 months ago

ported protobj to C5

File size: 1.3 KB
Line 
1;;;; run.scm - tests for protobj
2
3
4(import test protobj)
5
6
7(define a (%))
8(test "\"a\" parent is root" #t (eq? (^ a) (current-root-object)))
9(! a x 1)
10(test "\"a\" slot \"x\" is 1" 1 (? a x))
11(define b (% a))
12(test "\"b\" inherited slot \"x\" is 1" 1 (? b x))
13(! a x 42)
14(test "\"b\" slot \"x\" is now 42" 42 (? b x))
15(! b x 69)
16(test "\"b\" slot \"x\" is 69" 69 (? b x))
17(test "\"a\" slot \"x\" is still 42" 42 (? a x))
18(! a xplus (lambda (self n) (+ (? self x) n)))
19(test "42 + 7 = 49" 49 (@ a xplus 7))
20(test "69 + 7 = 76" 76 (@ b xplus 7))
21(test "42 + 7 = 49" 49 (@ a (xplus 1000) (xplus 7)))
22(define c (% a (y 101)))
23(test "\"c\" slot \"x\" is 42" 42 (? c x))
24(test "\"c\" slot \"y\" is 101" 101 (? c y))
25(define d (% a (x 1) (y 2) (z 3)))
26(test "\"d\" slot \"x\" is 1" 1 (? d x))
27(test "\"d\" slot \"y\" is 2" 2 (? d y))
28(test "\"d\" slot \"z\" is 3" 3 (? d z))
29
30#;(test
31  "Copying object-raw-clone functions"
32  `(((c . 9) (b . 8) (e . 7))
33    ((clone . ,object-raw-clone/no-slots-copy)
34     (a . 5) (d . 6) (e . 7) (b . 8) (c . 9)))
35  (let* ((o (% (% (% (current-root-object)
36                     (a 1) (b 2) (c 3))
37                  (b 4) (a 5) (d 6))
38               (e 7) (b 8) (c 9))))
39    (list
40     (protobj-internal:slots (object-raw-clone/copy-immed-slots o))
41     (protobj-internal:slots (object-raw-clone/copy-all-slots o)))))
42
43;; TODO: Add more tests.
44
45(test-exit)
Note: See TracBrowser for help on using the repository browser.