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

cells 2.2.1


Property svn:mimetype set to
application/xelc

File size:
1.8 KB

Line  

1  

2  (requirelibrary cells simpletests) 

3  (import cells chicken simpletests) 

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  (definetest (TYPED_CELLS) 

13  (check 

14  (define c% (makecellof number? positive?)) 

15  ((cellof? number? positive?) c%) 

16  (cellempty? c%) 

17  (c% 5) 

18  (not (cellempty? c%)) 

19  (define d% (makecellof boolean?)) 

20  (cellempty? d%) 

21  (d% #f) 

22  (not (cellempty? d%)) 

23  (not (d%)) 

24  ((cellof? boolean?) d%) 

25  (not ((cellof? number?) d%)) 

26  (= (c%) 5) 

27  (not (eqv? (c%) (d%))) 

28  ((cellof? number? positive?) c%) 

29  (= (c%) 5) 

30  (not ((cellof? number? zero?) c%)) 

31  ((cellof? number?) c%) 

32  ((cellof?) c%) 

33  (cellprune! c%) 

34  (cellempty? c%) 

35  (not (conditioncase (c% 5) 

36  ((exn) #f))) 

37  (define e% (makecellof number?)) 

38  (e% 5) 

39  (= (e%) 5) 

40  (not ((cellof? number? positive?) e%)) 

41  ((cellof? number?) e%) 

42  )) 

43  

44  (definetest (CELLS) 

45  (check 

46  (define cl (cell 5)) 

47  (cell? cl) 

48  (not (cell? 5)) 

49  ((cellof? number?) cl) 

50  (not ((cellof? list?) cl)) 

51  (= (cellref cl) 5) 

52  (cellset! cl 50) 

53  (= (cellref cl) 50) 

54  ;(cellset! cl 500) 

55  (set! (cellref cl) 500) 

56  (= (cellref cl) 500) 

57  (not (conditioncase (cellref 500) 

58  ((exn) #f))) 

59  (set! (cellref cl) 5000) 

60  (= 5000 (cellref cl)) 

61  )) 

62  

63  (definetest (STACKS) 

64  (check 

65  (define stack (cell '())) 

66  (cell? stack) 

67  ((cellof? list?) stack) 

68  (not ((cellof? 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  (compoundtest (cells) 

80  (TYPED_CELLS) 

81  (CELLS) 

82  (STACKS) 

83  ) 

84  

Note: See
TracBrowser
for help on using the repository browser.