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

Last change on this file was 39165, checked in by Kon Lovett, 9 months ago

incl bug so no types, just alias, bump ver

File size: 1.5 KB
Line 
1;;;; box-test.scm  -*- Scheme -*-
2;;;; Kon Lovett, Apr '20
3;;;; Kon Lovett, Jul '18
4
5(import test)
6
7(test-begin "Box")
8
9;;;
10
11(import box)
12(import (chicken base))
13(import (only (chicken port) with-output-to-string))
14(import (only (chicken memory representation) procedure-data))
15
16;should be there
17#; ;BUG incl file w/ dest override
18(include "box.types")
19
20;;
21
22(test-group "Box Mutable"
23        (let ((tbox (make-box (void))))
24    (test-assert (box? tbox))
25    (test "#&#<unspecified>" (with-output-to-string (cut display tbox)))
26    (box-set! tbox #t)
27    (test-assert (box-ref tbox))
28    (test-assert (not (box? 3))) )
29)
30
31(test-group "Box Immutable"
32        (let ((tbox (make-box #f #t)))
33    (test-assert (box? tbox))
34    (test "#&#f" (with-output-to-string (cut display tbox)))
35    (test-assert (not (box-ref tbox)))
36    (test-error (box-set! tbox #t)) )
37)
38
39(test-group "Box References"
40        (let* ((var (void))
41               (tbox (make-box-variable var)))
42    (test-assert (box? tbox))
43    (test-assert (box-variable? tbox))
44    (test-assert (not (box-location? tbox)))
45    (test "Unbound Box" (void) (box-ref tbox))
46    (set! (box-ref tbox) #t)
47    (test-assert "Bound Box" (box-ref tbox))
48    (test-assert "Bound Var" var)
49    (test-assert (not (box? 3))) )
50)
51
52(test-group "Box Swap"
53        (let ((tbox (make-box 0)))
54    (test-assert (box? tbox))
55    (test 1 (box-swap! tbox + 1))
56    (test 1 (box-ref tbox))
57    (test 2 (box-swap! tbox add1))
58    (test 2 (box-ref tbox)) )
59)
60
61;;;
62
63(test-end "Box")
64
65(test-exit)
Note: See TracBrowser for help on using the repository browser.