source: project/release/4/cells/trunk/tests/run.scm

Last change on this file was 32514, checked in by juergen, 5 years ago

cells 2.2.1

  • Property svn:mime-type set to application/x-elc
File size: 1.8 KB
Line 
1
2(require-library cells simple-tests)
3(import cells chicken simple-tests)
4
5(define (push st% val)
6  (st% (cons val (st%))))
7(define (top st%)
8  (car (st%)))
9(define (pop st%)
10  (st% (cdr (st%))))
11
12(define-test (TYPED_CELLS)
13  (check
14    (define c% (make-cell-of number? positive?))
15    ((cell-of? number? positive?) c%)
16    (cell-empty? c%)
17    (c% 5)
18    (not (cell-empty? c%))
19    (define d% (make-cell-of boolean?))
20    (cell-empty? d%)
21    (d% #f)
22    (not (cell-empty? d%))
23    (not (d%))
24    ((cell-of? boolean?) d%)
25    (not ((cell-of? number?) d%))
26    (= (c%) 5)
27    (not (eqv? (c%) (d%)))
28    ((cell-of? number? positive?) c%)
29    (= (c%) 5)
30    (not ((cell-of? number? zero?) c%))
31    ((cell-of? number?) c%)
32    ((cell-of?) c%)
33    (cell-prune! c%)
34    (cell-empty? c%)
35    (not (condition-case (c% -5)
36           ((exn) #f)))
37    (define e% (make-cell-of number?))
38    (e% -5)
39    (= (e%) -5)
40    (not ((cell-of? number? positive?) e%))
41    ((cell-of? number?) e%)
42    ))
43
44(define-test (CELLS)
45  (check
46    (define cl (cell 5))
47    (cell? cl)
48    (not (cell? 5))
49    ((cell-of? number?) cl)
50    (not ((cell-of? list?) cl))
51    (= (cell-ref cl) 5)
52    (cell-set! cl 50)
53    (= (cell-ref cl) 50)
54    ;(cell-set! cl 500)
55    (set! (cell-ref cl) 500)
56    (= (cell-ref cl) 500)
57    (not (condition-case (cell-ref 500)
58           ((exn) #f)))
59    (set! (cell-ref cl) 5000)
60    (= 5000 (cell-ref cl))
61    ))
62
63(define-test (STACKS)
64  (check
65    (define stack (cell '()))
66    (cell? stack)
67    ((cell-of? list?) stack)
68    (not ((cell-of? number?) stack))
69    (null? (stack))
70    (push stack 5)
71    (push stack 50)
72    (push stack 500)
73    (= 500 (top stack))
74    (pop stack)
75    (= 50 (top stack))
76    (pop stack)
77    (= 5 (top stack))))
78
79(compound-test (cells)
80  (TYPED_CELLS)
81  (CELLS)
82  (STACKS)
83  )
84 
Note: See TracBrowser for help on using the repository browser.