~ubuntu-branches/ubuntu/hardy/sigscheme/hardy-proposed

« back to all changes in this revision

Viewing changes to test/bigloo-bool.scm

  • Committer: Bazaar Package Importer
  • Author(s): NIIBE Yutaka
  • Date: 2006-05-23 21:46:41 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060523214641-6ix4gz34wpiehub8
Tags: 0.5.0-2
* debian/control (Build-Depends): Added ruby.
  Thanks to Frederik Schueler.  Closes: #368571
* debian/rules (clean): invoke 'distclean' instead of 'clean'.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
;*---------------------------------------------------------------------*/
 
2
;*    serrano/prgm/project/bigloo/recette/bool.scm                     */
 
3
;*                                                                     */
 
4
;*    Author      :  Manuel Serrano                                    */
 
5
;*    Creation    :  Tue Nov  3 09:16:12 1992                          */
 
6
;*    Last change :  Wed Apr  1 14:05:49 1998 (serrano)                */
 
7
;*                                                                     */
 
8
;*    On test les operations booleenes.                                */
 
9
;*---------------------------------------------------------------------*/
 
10
 
 
11
(load "./test/unittest-bigloo.scm")
 
12
 
 
13
;*---------------------------------------------------------------------*/
 
14
;*    predicat ...                                                     */
 
15
;*---------------------------------------------------------------------*/
 
16
(define (predicat x)
 
17
   (> x 5))
 
18
 
 
19
;*---------------------------------------------------------------------*/
 
20
;*    faux-predicat ...                                                */
 
21
;*---------------------------------------------------------------------*/
 
22
(define (faux-predicat x)
 
23
   (> x 5))
 
24
 
 
25
;*---------------------------------------------------------------------*/
 
26
;*    encore-faux ...                                                  */
 
27
;*---------------------------------------------------------------------*/
 
28
(define (encore-faux x)
 
29
   (> x 5))
 
30
 
 
31
;*---------------------------------------------------------------------*/
 
32
;*    local-pred-1 ...                                                 */
 
33
;*---------------------------------------------------------------------*/
 
34
(define (local-pred-1 x)
 
35
   (let ((pred (lambda (x) (< x 3))))
 
36
      (if (pred x) #t #f)))
 
37
 
 
38
;*---------------------------------------------------------------------*/
 
39
;*    local-pred-2 ...                                                 */
 
40
;*---------------------------------------------------------------------*/
 
41
(define (local-pred-2 x)
 
42
  (let* ((foo (lambda (x) (< x 3)))
 
43
         (bar (lambda (x) (if (foo x) 3 4)))
 
44
         (gee (lambda (x) (if (foo x) 3 4))))
 
45
    bar
 
46
    gee
 
47
    (if (foo x) #t #f)))
 
48
 
 
49
;*---------------------------------------------------------------------*/
 
50
;*    local-pred-3 ...                                                 */
 
51
;*---------------------------------------------------------------------*/
 
52
(define (local-pred-3 x)
 
53
  (let ((pred (lambda (x) (< x 3))))
 
54
    (pred x)))
 
55
 
 
56
;*---------------------------------------------------------------------*/
 
57
;*    test-bool ...                                                    */
 
58
;*---------------------------------------------------------------------*/
 
59
(define (test-bool)
 
60
   (test "or" (or #f #f) #f)
 
61
   (test "not" (not #f) #t)
 
62
   (test "and" (and #t #t) #t)
 
63
   (test "and" (and #t #f) #f)
 
64
   (test "if" (let ((x 1)) (if x x)) 1)
 
65
   (test "ifnot" (let ((x 1)) (if (not x) #t #f)) #f)
 
66
   (test "ifor" (let ((x 1) (y #f)) (if (or x y) x y)) 1)
 
67
   (test "ifand" (let ((x 1) (y #f)) (if (and x y) #t #f)) #f)
 
68
   (test "pred" (if (predicat 6) #t #f) #t)
 
69
   (test "faux" (if (faux-predicat 6) (faux-predicat 7) (faux-predicat 3)) #t)
 
70
   (test "encore-faux" (if (encore-faux 6) #t #f) #t)
 
71
   (test "local-pred-1" (local-pred-1 1) #t)
 
72
   (test "local-pred-2" (local-pred-2 1) #t)
 
73
   (test "local-pred-3" (if (local-pred-3 1) #t #f) #t))
 
74
 
 
75
(test-bool)
 
76
 
 
77
(total-report)