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

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

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

File size: 1.9 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Tue Jan 28 06:48:19 2003
4;;;; Contains: Tests of ASSERT
5
6(in-package :cl-test)
7
8(deftest assert.1
9  (assert t)
10  nil)
11
12(deftest assert.2
13  (assert t ())
14  nil)
15
16;;; I am assuming that when no places are given to ASSERT,
17;;; it doesn't invoke any interactive handler.
18
19(deftest assert.3
20  (let ((x nil))
21    (handler-bind
22     ((error #'(lambda (c)
23                 (setq x 17)
24                 (let ((r (find-restart 'continue c)))
25                   (when r (invoke-restart r))))))
26     (assert x)
27     x))
28  17)
29
30(deftest assert.3a
31  (let ((x nil))
32    (handler-bind
33     ((error #'(lambda (c)
34                 (setq x 17)
35                 (continue c))))
36     (assert x)
37     x))
38  17)
39
40
41;;; I don't yet know how to test the interactive version of ASSERT
42;;; that is normally invoked when places are given.
43
44;;; Tests of the syntax (at least)
45
46(deftest assert.4
47  (let (x)
48    (assert t (x)))
49  nil)
50
51(deftest assert.5
52  (let ((x (cons 'a 'b)))
53    (assert t ((car x) (cdr x))))
54  nil)
55
56(deftest assert.6
57  (let ((x (vector 'a 'b 'c)))
58    (assert t ((aref x 0) (aref x 1) (aref x 2))
59            "Vector x has value: ~A." x))
60  nil)
61
62(deftest assert.7
63  (let ((x nil))
64    (handler-bind
65     ((simple-error #'(lambda (c)
66                        (setq x 17)
67                        (continue c))))
68     (assert x () 'simple-error)
69     x))
70  17)
71
72(deftest assert.8
73  (let ((x 0))
74    (handler-bind
75     ((type-error #'(lambda (c)
76                        (incf x)
77                        (continue c))))
78     (assert (> x 5) () 'type-error)
79     x))
80  6)
81
82(deftest assert.9
83  (let ((x 0))
84    (handler-bind
85     ((type-error #'(lambda (c) (declare (ignore c))
86                        (incf x)
87                        (continue))))
88     (assert (> x 5) () 'type-error)
89     x))
90  6)
91
92;;; Test that explicit calls to macroexpand in subforms
93;;; are done in the correct environment
94
95(deftest assert.10
96  (macrolet
97   ((%m (z) z))
98   (assert (expand-in-current-env (%m t))))
99  nil)
100
101(deftest assert.11
102  (macrolet
103   ((%m (z) z))
104   (assert (expand-in-current-env (%m t)) () "Foo!"))
105  nil)
Note: See TracBrowser for help on using the repository browser.