source: trunk/source/tests/ansi-tests/block.lsp @ 8991

Last change on this file since 8991 was 8991, checked in by gz, 11 years ago

Check in the gcl ansi test suite (original, in preparation for making local changes)

File size: 1.5 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Sat Oct 12 12:30:46 2002
4;;;; Contains: Tests of BLOCK
5
6(in-package :cl-test)
7
8(deftest block.1
9  (block foo
10    (return-from foo 1))
11  1)
12
13(deftest block.2
14  (block nil
15    (block foo
16      (return 'good))
17    'bad)
18  good)
19
20(deftest block.3
21  (block done
22    (flet ((%f (x) (return-from done x)))
23      (%f 'good))
24    'bad)
25  good)
26
27(deftest block.4
28  (block foo
29    (block foo
30      (return-from foo 'bad))
31    'good)
32  good)
33
34(deftest block.5
35  (block done
36    (flet ((%f (x) (return-from done x)))
37      (mapcar #'%f '(good bad bad)))
38    'bad)
39  good)
40
41(deftest block.6
42  (block b1
43    (return-from b1 (values))
44    1))
45
46(deftest block.7
47  (block b1
48    (return-from b1 (values 1 2 3 4))
49    1)
50  1 2 3 4)
51
52(deftest block.8
53  (block foo)
54  nil)
55
56(deftest block.9
57  (block foo (values 'a 'b) (values 'c 'd))
58  c d)
59
60(deftest block.10
61  (block done
62    (flet ((%f (x) (return-from done x)))
63      (block done (mapcar #'%f '(good bad bad))))
64    'bad)
65  good)
66
67;;; Block has no tagbody
68(deftest block.11
69  (block done
70    (tagbody
71     (block nil
72       (go 10)
73       10
74       (return-from done 'bad))
75     10
76     (return-from done 'good)))
77  good)
78
79;;; Macros are expanded in the appropriate environment
80
81(deftest block.12
82  (macrolet ((%m (z) z))
83            (block foo (expand-in-current-env (%m :good))))
84  :good)
85
86#|
87(deftest return.error.1
88  (signals-error
89   (block nil
90     (return 'a 'b))
91   program-error)
92  t)
93|#
Note: See TracBrowser for help on using the repository browser.