tests: add regressions tests for deftype
authorDaniel Kochmański <daniel@turtleware.eu>
Tue, 18 Aug 2015 11:24:24 +0000 (13:24 +0200)
committerDaniel Kochmański <daniel@turtleware.eu>
Tue, 18 Aug 2015 11:24:24 +0000 (13:24 +0200)
Signed-off-by: Daniel Kochmański <daniel@turtleware.eu>
src/tests/bugs/test-ansi.lsp

index e884a39..52bf9e4 100644 (file)
@@ -1,5 +1,7 @@
 (in-package :cl-test)
 
+;; HyperSpec – 2.*
+
 ;;;;;;;;;;;;;;;;;;;;;
 ;; Readtable tests ;;
 ;;;;;;;;;;;;;;;;;;;;;
   #\a 3)
 
 \f
+
+;; HyperSpec – 3.*
+
+;;;;;;;;;;;;;;;;;;;
+;; Deftype tests ;;
+;;;;;;;;;;;;;;;;;;;
+
+(deftest test-ansi.deftype.ordinary.1
+    (progn
+      (deftype ordinary1 () `(member nil t))
+      (values (typep T  'ordinary1)
+              (typep :a 'ordinary1)))
+  T NIL)
+
+(deftest test-ansi.deftype.ordinary.2
+    (progn
+      (deftype ordinary2 (a b)
+        (if a
+            'CONS
+            `(INTEGER 0 ,b)))
+      (values (typep T        '(ordinary2 nil 3))
+              (typep 3        '(ordinary2 nil 4))
+              (typep T        '(ordinary2 T nil))
+              (typep '(1 . 2) '(ordinary2 T nil))))
+  nil t nil t)
+
+(deftest test-ansi.deftype.optional
+    (progn
+      (deftype optional (a &optional b)
+        (if a
+            'CONS
+            `(INTEGER 0 ,b)))
+      (values (typep 5        '(optional nil))
+              (typep 5        '(optional nil 4))))
+  t nil)
+
+(deftest test-ansi.deftype.nested
+    (progn
+      (deftype nested ((a &optional b) c . d)
+        (assert (listp d))
+        `(member ,a ,b ,c))
+      (values
+       (typep  1 '(nested (1 2) 3 4 5 6))
+       (typep  1 '(nested (2 2) 3 4 5 6))
+       (typep '* '(nested (3)   3))
+       (typep  3 '(nested (2)   3))))
+  t nil t t)
+
+\f