0.6.8.26:
[sbcl.git] / tests / clos-ignore.interactive.lisp
diff --git a/tests/clos-ignore.interactive.lisp b/tests/clos-ignore.interactive.lisp
new file mode 100644 (file)
index 0000000..1d69116
--- /dev/null
@@ -0,0 +1,62 @@
+;;;; To test the IGNORE/IGNORABLE behavior in CLOS, run COMPILE-FILE on
+;;;; this file and look at the output (warnings, etc.).
+;;;;
+;;;; (In sbcl-0.6.8.25, the handling of IGNORE and IGNORABLE in
+;;;; DEFMETHOD forms was rewritten to systematize the old PCL behavior.
+;;;; Now all required variables are IGNORABLE by default.)
+
+;;;; This software is part of the SBCL system. See the README file for
+;;;; more information.
+;;;;
+;;;; While most of SBCL is derived from the CMU CL system, the test
+;;;; files (like this one) were written from scratch after the fork
+;;;; from CMU CL.
+;;;; 
+;;;; This software is in the public domain and is provided with
+;;;; absolutely no warranty. See the COPYING and CREDITS files for
+;;;; more information.
+
+(in-package :cl-user)
+
+(defgeneric foo ((x t) (y t) &key &allow-other-keys))
+
+;;; should have no STYLE-WARNINGs (e.g. about unused vars)
+(defmethod foo ((x t) (y t))
+  nil)
+
+;;; should have no STYLE-WARNINGs
+(defmethod foo ((x t) (y t) &key &allow-other-keys)
+  (declare (ignore x)))
+
+;;; should have no STYLE-WARNINGs
+(defmethod foo ((x t) (y t) &key &allow-other-keys)
+  (declare (ignorable x y))
+  (declare (ignore y)))
+
+;;; should have no STYLE-WARNINGs
+(defmethod foo ((x t) (y t) &key &allow-other-keys)
+  x)
+
+;;; should have a STYLE-WARNING: using an IGNOREd variable
+(defmethod foo ((x t) (y t) &key &allow-other-keys)
+  (declare (ignore x y))
+  x)
+
+;;; should have no STYLE-WARNINGs
+(defmethod foo (x y &key &allow-other-keys)
+  (declare (ignore x y))
+  (call-next-method))
+
+;;; should have no STYLE-WARNINGs
+(defmethod foo ((x integer) (y t) &key &allow-other-keys)
+  (declare (ignore x y))
+  (call-next-method))
+
+;;; should have no STYLE-WARNINGs
+(defmethod foo ((x integer) (y t) &key &allow-other-keys)
+  (declare (ignore x))
+  (call-next-method))
+
+;;; should have a STYLE-WARNING: Z is unused.
+(defmethod foo ((x t) (y integer) &key z)
+  nil)