diff tests/automated/lisp-tests.el @ 4686:cdabd56ce1b5

Fix various small issues with the multiple-value implementation. lisp/ChangeLog addition: 2009-08-31 Aidan Kehoe <kehoea@parhasard.net> * byte-optimize.el (byte-optimize-form-code-walker): Be careful about discarding multiple values when optimising #'prog1 calls. (byte-optimize-or): Preserve any trailing nil, as this is a supported way to explicitly discard multiple values. (byte-optimize-cond-1): Discard multiple values with a singleton followed by no more clauses. * bytecomp.el (progn): (prog1): (prog2): Be careful about discarding multiple values in the byte-hunk handler of these three forms. * bytecomp.el (byte-compile-prog1, byte-compile-prog2): Don't call #'values explicitly, use `(or ,(pop form) nil) instead, since that compiles to bytecode, not a funcall. * bytecomp.el (byte-compile-values): With one non-const argument, byte-compile to `(or ,(second form) nil), not an explicit #'values call. * bytecomp.el (byte-compile-insert-header): Be nicer in the error message to emacs versions that don't understand our bytecode. src/ChangeLog addition: 2009-08-31 Aidan Kehoe <kehoea@parhasard.net> * eval.c (For, Fand): Don't declare val as REGISTER in these functions, for some reason it breaks the non-DEBUG union build. These functions are only called from interpreted code, the performance implication doesn't matter. Thank you Robert Delius Royar! * eval.c (Fmultiple_value_list_internal): Error on too many arguments. tests/ChangeLog addition: 2009-08-31 Aidan Kehoe <kehoea@parhasard.net> * automated/lisp-tests.el (Assert-rounding): Remove an overly-verbose failure message here. Correct a couple of tests which were buggy in themselves. Add three new tests, checking the behaviour of #'or and #'and when passed zero arguments, and a Known-Bug-Expect-Failure call involving letf and values. (The bug predates the C-level multiple-value implementation.)
author Aidan Kehoe <kehoea@parhasard.net>
date Sun, 06 Sep 2009 19:36:02 +0100
parents 2c64d2bbb316
children d0ea57eb3de4
line wrap: on
line diff
--- a/tests/automated/lisp-tests.el	Wed Sep 02 20:38:14 2009 -0600
+++ b/tests/automated/lisp-tests.el	Sun Sep 06 19:36:02 2009 +0100
@@ -1475,11 +1475,8 @@
 			 first one-round-result))
 	 (Assert (equal one-round-result (multiple-value-list
 					  (round first 1)))
-		 (format "checking (round %S 1) gives %S, types %S, actual %S, types %S"
-			 first one-round-result (mapcar #'type-of one-round-result)
-			 (multiple-value-list (round first 1))
-			 (mapcar #'type-of (multiple-value-list (round first 1)))))
-
+		 (format "checking (round %S 1) gives %S"
+			 first one-round-result))
 	 (Check-Error arith-error (round first 0))
 	 (Check-Error arith-error (round first 0.0))
 	 (Assert (equal two-round-result (multiple-value-list
@@ -1949,7 +1946,7 @@
        (multiple-value-function-returning-t ()
 	 (values t pi e degrees-to-radians radians-to-degrees))
        (multiple-value-function-returning-nil ()
-	 (values t pi e radians-to-degrees degrees-to-radians))
+	 (values nil pi e radians-to-degrees degrees-to-radians))
        (function-throwing-multiple-values ()
 	 (let* ((listing '(0 3 4 nil "string" symbol))
 		(tail listing)
@@ -2051,7 +2048,7 @@
 		 (cond ((multiple-value-function-returning-t))))))
    "Checking cond doesn't pass back multiple values in tests.")
   (Assert
-   (equal (list t pi e degrees-to-radians radians-to-degrees)
+   (equal (list nil pi e radians-to-degrees degrees-to-radians)
 	  (multiple-value-list
 	   (cond (t (multiple-value-function-returning-nil)))))
    "Checking cond passes back multiple values in clauses.")
@@ -2069,10 +2066,28 @@
 	  (multiple-value-list
 	   (catch 'VoN61Lo4Y (function-throwing-multiple-values)))))
   (Assert
-   (equal (list t pi e radians-to-degrees degrees-to-radians)
+   (equal (list t pi e degrees-to-radians radians-to-degrees)
 	  (multiple-value-list
 	   (loop
 	     for eye in `(a b c d ,e f g ,nil ,pi)
 	     do (when (null eye)
 		  (return (multiple-value-function-returning-t))))))
-   "Checking #'loop passes back multiple values correctly."))
+   "Checking #'loop passes back multiple values correctly.")
+  (Assert
+   (null (or))
+   "Checking #'or behaves correctly with zero arguments.")
+  (Assert
+   (eq t (and))
+   "Checking #'and behaves correctly with zero arguments.")
+  ;; This bug was here before the full multiple-value functionality
+  ;; was introduced (check it with (floor* pi) if you're
+  ;; curious). #'setf works, though, which is what most people are
+  ;; interested in. If you know the setf-method code better than I do,
+  ;; please post a patch; otherwise this is going to the back of the
+  ;; queue of things to do. I didn't break it :-) Aidan Kehoe, Mon Aug
+  ;; 31 10:45:50 GMTDT 2009. 
+  (Known-Bug-Expect-Error
+   void-variable
+   (letf (((values three one-four-one-five-nine) (floor pi)))
+     (* three one-four-one-five-nine))))
+