0.9.4.74:
[sbcl.git] / tests / compiler.test.sh
index 48597b5..25c208c 100644 (file)
@@ -265,7 +265,7 @@ expect_failed_compile $tmpfilename
 # references to the unbound variable.
 cat > $tmpfilename <<EOF
 (defmacro macro-with-unbound-variables (foo)
-  `(print ,bar))
+  \`(print ,bar))
 
 (macro-with-unbound-variables 'xxx)
 EOF
@@ -286,6 +286,64 @@ cat > $tmpfilename <<EOF
 EOF
 expect_failed_compile $tmpfilename
 
+# This should be clean
+cat > $tmpfilename <<EOF
+(defvar *string* (make-string 10 :element-type 'base-char))
+EOF
+expect_clean_compile $tmpfilename
+
+# This should style-warn (but not warn or otherwise fail) as the call
+# to FORMAT has too many arguments, which is bad style but not
+# otherwise fatal.
+cat > $tmpfilename <<EOF
+(defun foo (a b)
+  (format nil "abc~~def" a b))
+EOF
+expect_warned_compile $tmpfilename
+
+# Tests that destructive-functions on known-constant data cause
+# compile-time warnings.
+cat > $tmpfilename <<EOF
+(let ((string "foo"))
+  (defun foo ()
+    (setf string "bar")))
+EOF
+expect_clean_compile $tmpfilename
+
+cat > $tmpfilename <<EOF
+(defun foo ()
+  (let (result)
+    (nreverse result)))
+EOF
+expect_clean_compile $tmpfilename
+
+cat > $tmpfilename <<EOF
+(defun bar ()
+  (let ((result ""))
+    (nreverse result)))  
+EOF
+expect_clean_compile $tmpfilename
+
+cat > $tmpfilename <<EOF
+(let ((string "foo"))
+  (defun foo ()
+    (replace string "bar")))
+EOF
+expect_failed_compile $tmpfilename
+
+cat > $tmpfilename <<EOF
+(defun foo ()
+  (setf (char "bar" 0) #\1))
+EOF
+expect_failed_compile $tmpfilename
+
+cat > $tmpfilename <<EOF
+(let ((foo '(1 2 3)))
+  (defun foo ()
+    (nconc foo foo)))
+EOF
+expect_failed_compile $tmpfilename
+
 rm $tmpfilename
 rm $compiled_tmpfilename