close Warning: Can't use blame annotator:
svn blame failed on release/4/cells/trunk/tests/run.scm: 195004 - Cannot calculate blame information for binary file 'file:///usr/local/repos/chicken-eggs/release/4/cells/trunk/tests/run.scm'

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

Last change on this file since 31167 was 31167, checked in by juergen, 6 years ago

cells 1.2 with cell->closure

  • Property svn:mime-type set to application/x-elc
File size: 1.0 KB
RevLine 
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 (CELLS)
13  (check
14    (define cl (cell 5))
15    (cell? cl)
16    (not (cell? 5))
17    ((cell-of? number?) cl)
18    (not ((cell-of? list?) cl))
19    (= (cell-ref cl) 5)
20    (cell-set! cl 50)
21    (= (cell-ref cl) 50)
22    (cell-set! cl 500)
23    (= (cell-ref cl) 500)
24    (not (condition-case (cell-ref 500)
25           ((exn) #f)))
26    (define cl% (cell->closure cl))
27    (cl%) ; -> 500
28    (cl% 5)
29    (cl%) ; -> 500
30    ))
31
32(define-test (STACKS)
33  (check
34    (define stack (cell '()));'#,(% ()))
35    (cell? stack)
36    ((cell-of? list?) stack)
37    (not ((cell-of? number?) stack))
38    (define stack% (cell->closure stack))
39    (null? (stack%))
40    (push stack% 5)
41    (push stack% 50)
42    (push stack% 500)
43    (= 500 (top stack%))
44    (pop stack%)
45    (= 50 (top stack%))
46    (pop stack%)
47    (= 5 (top stack%))))
48
49(compound-test (cells)
50  (CELLS)
51  (STACKS)
52  )
53 
Note: See TracBrowser for help on using the repository browser.