Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
ansi-test
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michał Herda
ansi-test
Commits
7bf677da
Commit
7bf677da
authored
22 years ago
by
pfdietz
Browse files
Options
Downloads
Patches
Plain Diff
Added tests for CASE, ECASE.
parent
c3342f17
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
ansi-tests/case.lsp
+58
-0
58 additions, 0 deletions
ansi-tests/case.lsp
ansi-tests/ecase.lsp
+145
-0
145 additions, 0 deletions
ansi-tests/ecase.lsp
ansi-tests/gclload2.lsp
+1
-0
1 addition, 0 deletions
ansi-tests/gclload2.lsp
with
204 additions
and
0 deletions
ansi-tests/case.lsp
+
58
−
0
View file @
7bf677da
...
...
@@ -92,6 +92,64 @@
((#\z #\a #\y) 40))
40)
(deftest case.21 (case 1 (1 (values))))
(deftest case.22 (case 2 (t (values))))
(deftest case.23 (case 1 (1 (values 'a 'b 'c)))
a b c)
(deftest case.24 (case 2 (t (values 'a 'b 'c)))
a b c)
;;; Show that the key expression is evaluated only once.
(deftest case.25
(let ((x 0))
(values
(case (progn (incf x) 'c)
(a 1)
(b 2)
(c 3)
(t 4))
x))
3 1)
;;; Repeated keys are allowed (all but the first are ignored)
(deftest case.26
(case 'b ((a b c) 10) (b 20))
10)
(deftest case.27
(case 'b (b 20) ((a b c) 10))
20)
(deftest case.28
(case 'b (b 20) (b 10) (t 0))
20)
;;; There are implicit progns
(deftest case.29
(let ((x nil))
(values
(case 2
(1 (setq x 'a) 'w)
(2 (setq x 'b) 'y)
(t (setq x 'c) 'z))
x))
y b)
(deftest case.30
(let ((x nil))
(values
(case 10
(1 (setq x 'a) 'w)
(2 (setq x 'b) 'y)
(t (setq x 'c) 'z))
x))
z c)
(deftest case.31
(case (values 'b 'c) (c 0) ((a b) 10) (t 20))
10)
This diff is collapsed.
Click to expand it.
ansi-tests/ecase.lsp
0 → 100644
+
145
−
0
View file @
7bf677da
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Fri Oct 18 20:17:30 2002
;;;; Contains: Tests for ECASE
(in-package :cl-test)
(deftest ecase.1
(ecase 'b (a 1) (b 2) (c 3))
2)
(deftest ecase.2
(classify-error (ecase 1))
type-error)
(deftest ecase.3
(classify-error (ecase 1 (a 1) (b 2) (c 3)))
type-error)
;;; It is legal to use T or OTHERWISE as key designators
;;; in ECASE forms. They have no special meaning here.
(deftest ecase.4
(classify-error (ecase 1 (t nil)))
type-error)
(deftest ecase.5
(classify-error (ecase 1 (otherwise nil)))
type-error)
(deftest ecase.6
(ecase 'b ((a z) 1) ((y b w) 2) ((b c) 3))
2)
(deftest ecase.7
(ecase 'z
((a b c) 1)
((d e) 2)
((f z g) 3))
3)
(deftest ecase.8
(ecase (1+ most-positive-fixnum)
(#.(1+ most-positive-fixnum) 'a))
a)
(deftest ecase.9
(classify-error (ecase nil (nil 'a)))
type-error)
(deftest ecase.10
(ecase nil ((nil) 'a))
a)
(deftest ecase.11
(ecase 'a (b 0) (a (values 1 2 3)) (c nil))
1 2 3)
(deftest ecase.12
(classify-error (ecase t (a 10)))
type-error)
(deftest ecase.13
(ecase t ((t) 10) (t 20))
10)
(deftest ecase.14
(let ((x (list 'a 'b)))
(eval `(ecase (quote ,x) ((,x) 1) (a 2))))
1)
(deftest ecase.15
(classify-error (ecase 'otherwise ((t) 10)))
type-error)
(deftest ecase.16
(classify-error (ecase t ((otherwise) 10)))
type-error)
(deftest ecase.17
(classify-error (ecase 'a (b 0) (c 1) (otherwise 2)))
type-error)
(deftest ecase.18
(classify-error (ecase 'a (b 0) (c 1) ((otherwise) 2)))
type-error)
(deftest ecase.19
(classify-error (ecase 'a (b 0) (c 1) ((t) 2)))
type-error)
(deftest ecase.20
(ecase #\a
((#\b #\c) 10)
((#\d #\e #\A) 20)
(() 30)
((#\z #\a #\y) 40))
40)
(deftest ecase.21 (ecase 1 (1 (values)) (2 'a)))
(deftest ecase.23 (ecase 1 (1 (values 'a 'b 'c)))
a b c)
;;; Show that the key expression is evaluated only once.
(deftest ecase.25
(let ((x 0))
(values
(ecase (progn (incf x) 'c)
(a 1)
(b 2)
(c 3)
(d 4))
x))
3 1)
;;; Repeated keys are allowed (all but the first are ignored)
(deftest ecase.26
(ecase 'b ((a b c) 10) (b 20))
10)
(deftest ecase.27
(ecase 'b (b 20) ((a b c) 10))
20)
(deftest ecase.28
(ecase 'b (b 20) (b 10) (d 0))
20)
;;; There are implicit progns
(deftest ecase.29
(let ((x nil))
(values
(ecase 2
(1 (setq x 'a) 'w)
(2 (setq x 'b) 'y)
(3 (setq x 'c) 'z))
x))
y b)
(deftest ecase.31
(ecase (values 'b 'c) (c 0) ((a b) 10) (d 20))
10)
This diff is collapsed.
Click to expand it.
ansi-tests/gclload2.lsp
+
1
−
0
View file @
7bf677da
...
...
@@ -23,6 +23,7 @@
(load "defparameter.lsp")
(load "defvar.lsp")
(load "destructuring-bind.lsp")
(load "ecase.lsp")
(load "equal.lsp")
(load "equalp.lsp")
(load "eql.lsp")
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment