File: bigloo-bool.scm

package info (click to toggle)
sigscheme 0.8.3-8
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 12,236 kB
  • ctags: 7,208
  • sloc: lisp: 37,498; ansic: 30,948; sh: 9,257; makefile: 744; asm: 333; ruby: 288
file content (121 lines) | stat: -rw-r--r-- 6,049 bytes parent folder | download | duplicates (15)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
;;    A practical implementation for the Scheme programming language   
;;                                                                     
;;                                    ,--^,                            
;;                              _ ___/ /|/                             
;;                          ,;'( )__, ) '                              
;;                         ;;  //   L__.                               
;;                         '   \\   /  '                               
;;                              ^   ^                                  
;;                                                                     
;;               Copyright (c) 1992-2004 Manuel Serrano                
;;                                                                     
;;     Bug descriptions, use reports, comments or suggestions are      
;;     welcome. Send them to                                           
;;       bigloo@sophia.inria.fr                                        
;;       http://www.inria.fr/mimosa/fp/Bigloo                                 
;;                                                                     
;;   This program is free software; you can redistribute it and/or modify
;;   it under the terms of the GNU General Public License as published by 
;;   the Free Software Foundation; either version 2 of the License, or 
;;   (at your option) any later version. More precisely,
;;
;;      - The compiler and the tools are distributed under the terms of the
;;      GNU General Public License.
;;
;;      - The Bigloo run-time system and the libraries are distributed under 
;;      the terms of the GNU Library General Public License. The source code
;;      of the Bigloo runtime system is located in the ./runtime directory.
;;      The source code of the FairThreads library is located in the
;;      ./fthread directory.
;;
;;   This program is distributed in the hope that it will be useful,   
;;   but WITHOUT ANY WARRANTY; without even the implied warranty of    
;;   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     
;;   GNU General Public License for more details.                      
;;                                                                     
;;   You should have received a copy of the GNU General Public         
;;   License along with this program; if not, write to the Free        
;;   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,   
;;   MA 02111-1307, USA.                                               

;*---------------------------------------------------------------------*/
;*    serrano/prgm/project/bigloo/recette/bool.scm                     */
;*                                                                     */
;*    Author      :  Manuel Serrano                                    */
;*    Creation    :  Tue Nov  3 09:16:12 1992                          */
;*    Last change :  Wed Apr  1 14:05:49 1998 (serrano)                */
;*                                                                     */
;*    On test les operations booleenes.                                */
;*---------------------------------------------------------------------*/

;; ChangeLog
;;
;; 2005-08-18 kzk     Copied from Bigloo 2.6e and adapted to SigScheme

(load "./test/unittest-bigloo.scm")

;*---------------------------------------------------------------------*/
;*    predicat ...                                                     */
;*---------------------------------------------------------------------*/
(define (predicat x)
   (> x 5))

;*---------------------------------------------------------------------*/
;*    faux-predicat ...                                                */
;*---------------------------------------------------------------------*/
(define (faux-predicat x)
   (> x 5))

;*---------------------------------------------------------------------*/
;*    encore-faux ...                                                  */
;*---------------------------------------------------------------------*/
(define (encore-faux x)
   (> x 5))

;*---------------------------------------------------------------------*/
;*    local-pred-1 ...                                                 */
;*---------------------------------------------------------------------*/
(define (local-pred-1 x)
   (let ((pred (lambda (x) (< x 3))))
      (if (pred x) #t #f)))

;*---------------------------------------------------------------------*/
;*    local-pred-2 ...                                                 */
;*---------------------------------------------------------------------*/
(define (local-pred-2 x)
  (let* ((foo (lambda (x) (< x 3)))
	 (bar (lambda (x) (if (foo x) 3 4)))
	 (gee (lambda (x) (if (foo x) 3 4))))
    bar
    gee
    (if (foo x) #t #f)))

;*---------------------------------------------------------------------*/
;*    local-pred-3 ...                                                 */
;*---------------------------------------------------------------------*/
(define (local-pred-3 x)
  (let ((pred (lambda (x) (< x 3))))
    (pred x)))

;*---------------------------------------------------------------------*/
;*    test-bool ...                                                    */
;*---------------------------------------------------------------------*/
(define (test-bool)
   (test "or" (or #f #f) #f)
   (test "not" (not #f) #t)
   (test "and" (and #t #t) #t)
   (test "and" (and #t #f) #f)
   (test "if" (let ((x 1)) (if x x)) 1)
   (test "ifnot" (let ((x 1)) (if (not x) #t #f)) #f)
   (test "ifor" (let ((x 1) (y #f)) (if (or x y) x y)) 1)
   (test "ifand" (let ((x 1) (y #f)) (if (and x y) #t #f)) #f)
   (test "pred" (if (predicat 6) #t #f) #t)
   (test "faux" (if (faux-predicat 6) (faux-predicat 7) (faux-predicat 3)) #t)
   (test "encore-faux" (if (encore-faux 6) #t #f) #t)
   (test "local-pred-1" (local-pred-1 1) #t)
   (test "local-pred-2" (local-pred-2 1) #t)
   (test "local-pred-3" (if (local-pred-3 1) #t #f) #t))

(test-bool)

(total-report)