Commit f4ee69e9 authored by pfdietz's avatar pfdietz
Browse files

Added tests to confirm that MACRO-FUNCTIONs have the correct error behavior...

Added tests to confirm that MACRO-FUNCTIONs have the correct error behavior when called with the wrong number of arguments.
parent 98a78667
......@@ -55,3 +55,16 @@
i a b c d))
4 4 1 2 3 4)
(deftest and.error.1
(classify-error (funcall (macro-function 'and)))
program-error)
(deftest and.error.2
(classify-error (funcall (macro-function 'and)
'(and)))
program-error)
(deftest and.error.3
(classify-error (funcall (macro-function 'and)
'(and) nil nil))
program-error)
\ No newline at end of file
......@@ -1438,3 +1438,18 @@ the condition to go uncaught if it cannot be classified."
(loop for e on plist by #'cddr
when (eql (car e) prop)
collect (cadr e)))
(defmacro def-macro-test (test-name macro-form)
(let ((macro-name (car macro-form)))
(assert (symbolp macro-name))
`(deftest ,test-name
(values
(eqlt (classify-error (funcall (macro-function ',macro-name)))
'program-error)
(eqlt (classify-error (funcall (macro-function ',macro-name)
',macro-form))
'program-error)
(eqlt (classify-error (funcall (macro-function ',macro-name)
',macro-form nil nil))
'program-error))
t t t)))
\ No newline at end of file
......@@ -194,3 +194,17 @@
;;; (deftest case.error.1
;;; (classify-error (case))
;;; program-error)
(deftest case.error.1
(classify-error (funcall (macro-function 'case)))
program-error)
(deftest case.error.2
(classify-error (funcall (macro-function 'case)
'(case t)))
program-error)
(deftest case.error.3
(classify-error (funcall (macro-function 'case)
'(case t) nil nil))
program-error)
\ No newline at end of file
......@@ -197,3 +197,17 @@
;;; (deftest ccase.error.1
;;; (classify-error (ccase))
;;; program-error)
(deftest ccase.error.1
(classify-error (funcall (macro-function 'ccase)))
program-error)
(deftest ccase.error.2
(classify-error (funcall (macro-function 'ccase)
'(ccase t)))
program-error)
(deftest ccase.error.3
(classify-error (funcall (macro-function 'ccase)
'(ccase t) nil nil))
program-error)
\ No newline at end of file
......@@ -80,3 +80,17 @@
10
(return-from done 'good)))
good)
(deftest cond.error.1
(classify-error (funcall (macro-function 'cond)))
program-error)
(deftest cond.error.2
(classify-error (funcall (macro-function 'cond)
'(cond)))
program-error)
(deftest cond.error.3
(classify-error (funcall (macro-function 'cond)
'(cond) nil nil))
program-error)
......@@ -81,9 +81,10 @@
(deftest ctypecase.13
(ctypecase 'a
(number 'bad)
(#.(find-class 'symbol nil) 'good))
(let ((x 'a))
(ctypecase x
(number 'bad)
(#.(find-class 'symbol nil) 'good)))
good)
(deftest ctypecase.14
......@@ -97,3 +98,17 @@
(return-from done 'good)))
good)
(deftest ctypecase.error.1
(classify-error (funcall (macro-function 'ctypecase)))
program-error)
(deftest ctypecase.error.2
(classify-error (funcall (macro-function 'ctypecase)
'(ctypecase t)))
program-error)
(deftest ctypecase.error.3
(classify-error (funcall (macro-function 'ctypecase)
'(ctypecase t)
nil nil))
program-error)
\ No newline at end of file
......@@ -43,3 +43,19 @@
;;; "This is a docstring"
;;; "This is an unnecessary extra argument."))
;;; program-error)
(deftest defconstant.error.1
(classify-error (funcall (macro-function 'defconstant)))
program-error)
(deftest defconstant.error.2
(classify-error (funcall (macro-function 'defconstant)
'(defconstant +nonexistent-constant+ 0)))
program-error)
(deftest defconstant.error.3
(classify-error (funcall (macro-function 'defconstant)
'(defconstant +nonexistent-constant+ 0)
nil nil))
program-error)
\ No newline at end of file
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Sun Apr 20 12:33:02 2003
;;;; Contains: Tests of DEFINE-COMPILER-MACRO
(in-package :cl-test)
;;; Need to add non-error tests
(deftest define-compiler-macro.error.1
(classify-error (funcall (macro-function 'define-compiler-macro)))
program-error)
(deftest define-compiler-macro.error.2
(classify-error (funcall (macro-function 'define-compiler-macro)
'(definee-compiler-macro nonexistent-function ())))
program-error)
(deftest define-compiler-macro.error.3
(classify-error (funcall (macro-function 'define-compiler-macro)
'(definee-compiler-macro nonexistent-function ())
nil nil))
program-error)
......@@ -81,3 +81,5 @@
;;; "extra illegal argument"))
;;; program-error)
(def-macro-test define-modify-macro.error.1
(define-modify-macro nonexistent-modify-macro () foo))
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Sun Apr 20 17:19:35 2003
;;;; Contains: Tests of DEFINE-SETF-EXPANDER
(in-package :cl-test)
;;; Need to add non-error tests
(def-macro-test define-setf-expander.error.1
(define-setf-expander nonexistent-access-fn (x)))
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Sun Apr 20 12:55:05 2003
;;;; Contains: Tests of DEFINE-SYMBOL-MACRO
(in-package :cl-test)
(deftest define-symbol-macro.error.1
(classify-error (funcall (macro-function 'define-symbol-macro)))
program-error)
(deftest define-symbol-macro.error.2
(classify-error (funcall (macro-function 'define-symbol-macro)
'(define-symbol-macro
nonexistent-symbol-macro nil)))
program-error)
(deftest define-symbol-macro.error.3
(classify-error (funcall (macro-function 'define-symbol-macro)
'(define-symbol-macro
nonexistent-symbol-macro nil)
nil nil))
program-error)
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Sun Apr 20 12:35:24 2003
;;;; Contains: Tests of DEFMACRO
(in-package :cl-test)
;;; Need to add non-error tests
(deftest defmacro.error.1
(classify-error (funcall (macro-function 'defmacro)))
program-error)
(deftest defmacro.error.2
(classify-error (funcall (macro-function 'defmacro)
'(defmacro nonexistent-macro ())))
program-error)
(deftest defmacro.error.3
(classify-error (funcall (macro-function 'defmacro)
'(defmacro nonexistent-macro ())
nil nil))
program-error)
......@@ -64,3 +64,19 @@
;;; "documentation"
;;; "illegal extra argument"))
;;; program-error)
(deftest defparameter.error.1
(classify-error (funcall (macro-function 'defparameter)))
program-error)
(deftest defparameter.error.2
(classify-error (funcall (macro-function 'defparameter)
'(defparameter *nonexistent-variable* nil)))
program-error)
(deftest defparameter.error.3
(classify-error (funcall (macro-function 'defparameter)
'(defparameter *nonexistent-variable* nil)
nil nil))
program-error)
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Sun Apr 20 17:18:01 2003
;;;; Contains: Tests of DEFSETF
(in-package :cl-test)
;;; Need to add non-error tests
(def-macro-test defsetf.error.1 (defsetf nonexistent-access-fn
nonexistent-update-fn))
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Sun Apr 20 12:56:56 2003
;;;; Contains: Tests of DEFTYPE
(in-package :cl-test)
(deftest deftype.error.1
(classify-error (funcall (macro-function 'deftype)))
program-error)
(deftest deftype.error.2
(classify-error (funcall (macro-function 'deftype)
'(deftype nonexistent-type () nil)))
program-error)
(deftest deftype.error.3
(classify-error (funcall (macro-function 'deftype)
'(deftype nonexistent-type () nil)
nil nil))
program-error)
......@@ -5,15 +5,20 @@
(in-package :cl-test)
#|
(deftest defun.error.1
(classify-error (defun))
(classify-error (funcall (macro-function 'defun)))
program-error)
(deftest defun.error.2
(classify-error (defun ignored-defun-name))
(classify-error (funcall (macro-function 'defun)
'(defun nonexistent-function ())))
program-error)
(deftest defun.error.3
(classify-error (funcall (macro-function 'defun)
'(defun nonexistent-function ())
nil nil))
program-error)
|#
;;; Tests for implicit blocks
......
......@@ -62,3 +62,19 @@
;;; (classify-error (defvar *ignored-defvar-name* nil "documentation"
;;; "illegal extra argument"))
;;; program-error)
(deftest defvar.error.1
(classify-error (funcall (macro-function 'defvar)))
program-error)
(deftest defvar.error.2
(classify-error (funcall (macro-function 'defvar)
'(defvar *nonexistent-variable* nil)))
program-error)
(deftest defvar.error.3
(classify-error (funcall (macro-function 'defvar)
'(defvar *nonexistent-variable* nil)
nil nil))
program-error)
......@@ -129,3 +129,18 @@
;;; (classify-error (destructuring-bind x))
;;; program-error)
(deftest destructuring-bind.error.7
(classify-error (funcall (macro-function 'destructuring-bind)))
program-error)
(deftest destructuring-bind.error.8
(classify-error (funcall (macro-function 'destructuring-bind)
'(destructuring-bind (a . b) '(1 2) nil)))
program-error)
(deftest destructuring-bind.error.9
(classify-error (funcall (macro-function 'destructuring-bind)
'(destructuring-bind (a . b) '(1 2) nil)
nil nil))
program-error)
......@@ -158,3 +158,18 @@
10
(return-from done 'good)))
good)
(deftest ecase.error.1
(classify-error (funcall (macro-function 'ecase)))
program-error)
(deftest ecase.error.2
(classify-error (funcall (macro-function 'ecase)
'(ecase t)))
program-error)
(deftest ecase.error.3
(classify-error (funcall (macro-function 'ecase)
'(ecase t)
nil nil))
program-error)
......@@ -70,4 +70,17 @@
(return 'good)))
good)
(deftest etypecase.error.1
(classify-error (funcall (macro-function 'etypecase)))
program-error)
(deftest etypecase.error.2
(classify-error (funcall (macro-function 'etypecase)
'(etypecase t)))
program-error)
(deftest etypecase.error.3
(classify-error (funcall (macro-function 'etypecase)
'(etypecase t)
nil nil))
program-error)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment