41d7f8899a718aedf3fe5c90e7a0ba3e4dec95f5
[sbcl.git] / tests / clos.test.sh
1 #!/bin/sh
2
3 # This software is part of the SBCL system. See the README file for
4 # more information.
5 #
6 # While most of SBCL is derived from the CMU CL system, the test
7 # files (like this one) were written from scratch after the fork
8 # from CMU CL.
9
10 # This software is in the public domain and is provided with
11 # absolutely no warranty. See the COPYING and CREDITS files for
12 # more information.
13
14 # Check that compiling and loading the file $1 generates an error
15 # at load time; also that just loading it directly (into the
16 # interpreter) generates an error.
17 expect_load_error ()
18 {
19     # Test compiling and loading.
20     $SBCL <<EOF
21         (compile-file "$1")
22         ;;; But loading the file should fail.
23         (multiple-value-bind (value0 value1) (ignore-errors (load *))
24             (assert (null value0))
25             (format t "VALUE1=~S (~A)~%" value1 value1)
26             (assert (typep value1 'error)))
27         (sb-ext:quit :unix-status 52)
28 EOF
29     if [ $? != 52 ]; then
30         echo compile-and-load $1 test failed: $?
31         exit 1
32     fi
33
34     # Test loading into the interpreter.
35     $SBCL <<EOF
36         (multiple-value-bind (value0 value1) (ignore-errors (load "$1"))
37             (assert (null value0))
38             (format t "VALUE1=~S (~A)~%" value1 value1)
39             (assert (typep value1 'error)))
40         (sb-ext:quit :unix-status 52)
41 EOF
42     if [ $? != 52 ]; then
43         echo load-into-interpreter $1 test failed: $?
44         exit 1
45     fi
46 }
47
48 base_tmpfilename="clos-test-$$-tmp"
49 tmpfilename="$base_tmpfilename.lisp"
50 compiled_tmpfilename="$base_tmpfilename.fasl"
51
52 # This should fail, but didn't until sbcl-0.6.12.7, with Martin
53 # Atzmueller's port of Pierre Mai's fixes.
54 cat > $tmpfilename <<EOF
55     (in-package :cl-user)
56     ;; This definition has too many qualifiers, so loading the
57     ;; DEFMETHOD should fail.
58     (defmethod zut progn :around ((x integer)) (print "integer"))
59 EOF
60 expect_load_error $tmpfilename
61
62 # Even before sbcl-0.6.12.7, this would fail as it should. Let's
63 # make sure that it still does.
64 cat > $tmpfilename <<EOF
65     (in-package :cl-user)
66     (defgeneric zut (x) (:method-combination progn))
67     ;; This definition is missing the PROGN qualifier, and so the
68     ;; DEFMETHOD should fail.
69     (defmethod zut ((x integer)) (print "integer"))
70 EOF
71 expect_load_error $tmpfilename
72
73 # Even before sbcl-0.6.12.7, this would fail as it should, but Martin
74 # Atzmueller's port of Pierre Mai's fixes caused it to generate more
75 # correct text in the error message. We can't check that in a regression
76 # test until AI gets a mite stronger, but at least we can check that
77 # the problem is still detected.
78 cat > $tmpfilename <<EOF
79     (in-package :cl-user)
80     (defgeneric zut (x) (:method-combination progn))
81     ;; This definition has too many qualifiers, so loading the
82     ;; DEFMETHOD should fail.
83     (defmethod zut progn :around ((x integer)) (print "integer"))
84 EOF
85 expect_load_error $tmpfilename
86
87 rm $tmpfilename
88 rm $compiled_tmpfilename
89
90 # success 
91 exit 104