source: project/release/5/box/trunk/tests/box-test.scm @ 36153

Last change on this file since 36153 was 36153, checked in by Kon Lovett, 3 years ago

C5 rel 3.0.0

File size: 1.3 KB
Line 
1;;;; box-test.scm  -*- Scheme -*-
2;;;; Kon Lovett, Jul '18
3
4(import test)
5
6(test-begin "Box")
7
8;;;
9
10(import box)
11
12(test-group "Box Mutable"
13        (let ((tbox #f))
14    (test-assert (make-box (void)))
15    (set! tbox (make-box (void)))
16    (test-assert (box? tbox))
17    (box-set! tbox #t)
18    (test-assert (box-ref tbox))
19    (test-assert (not (box? 3))) )
20)
21
22(test-group "Box Immutable"
23        (let ((tbox #f))
24    (test-assert (make-box #f #t))
25    (set! tbox (make-box #f #t))
26    (test-assert (box? tbox))
27    (test-assert (not (box-ref tbox)))
28    (test-error (box-set! tbox #t)) )
29)
30
31(test-group "Box References"
32        (let ((var (void))
33        (tbox #f))
34    (test-assert (make-box-variable var))
35    (set! tbox (make-box-variable var))
36    (test-assert (box? tbox))
37    (test-assert (box-variable? tbox))
38    (test-assert (not (box-location? tbox)))
39    (test "Unbound Box" (void) (box-ref tbox))
40    (set! (box-ref tbox) #t)
41    (test-assert "Bound Box" (box-ref tbox))
42    (test-assert "Bound Var" var)
43    (test-assert (not (box? 3))) )
44)
45
46(test-group "Box Swap"
47        (let ((tbox #f))
48    (test-assert (make-box (void)))
49    (set! tbox (make-box 0))
50    (test-assert (box? tbox))
51    (test 1 (box-swap! tbox + 1))
52    (test 1 (box-ref tbox))
53    (test 2 (box-swap! tbox add1))
54    (test 2 (box-ref tbox)) )
55)
56
57;;;
58
59(test-end "Box")
60
61(test-exit)
Note: See TracBrowser for help on using the repository browser.