;;;; 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.
;;;; 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.
;;;; This software is in the public domain and is provided with
;;;; absolutely no warranty. See the COPYING and CREDITS files for
;;;; more information.
;;; The bug reported by Alexei Dejneka on sbcl-devel 2001-09-03
;;; is fixed now.
(assert (equal (let ((hash (make-hash-table)))
;;; The bug reported by Alexei Dejneka on sbcl-devel 2001-09-03
;;; is fixed now.
(assert (equal (let ((hash (make-hash-table)))
- (setf (gethash 'key1 hash) 'val1)
- (setf (gethash 'key2 hash) 'val2)
- (sort (loop for key being each hash-key in hash
- collect key)
- #'string<))
- '(key1 key2)))
+ (setf (gethash 'key1 hash) 'val1)
+ (setf (gethash 'key2 hash) 'val2)
+ (sort (loop for key being each hash-key in hash
+ collect key)
+ #'string<))
+ '(key1 key2)))
;;; Bug 81, reported by Wolfhard Buss on cmucl-help 2001-02-14, was
;;; fixed by Alexey Dejneka's patch on sbcl-devel 2001-09-30.
(assert (equal '(0.0 1.0 2.0 3.0)
;;; Bug 81, reported by Wolfhard Buss on cmucl-help 2001-02-14, was
;;; fixed by Alexey Dejneka's patch on sbcl-devel 2001-09-30.
(assert (equal '(0.0 1.0 2.0 3.0)
- (loop with (a . b) of-type float = '(0.0 . 1.0)
- and (c . d) of-type float = '(2.0 . 3.0)
- return (list a b c d))))
+ (loop with (a . b) of-type float = '(0.0 . 1.0)
+ and (c . d) of-type float = '(2.0 . 3.0)
+ return (list a b c d))))
;;; a bug reported and fixed by Alexey Dejneka sbcl-devel 2001-10-05:
;;; The type declarations should apply, hence under Python's
;;; declarations-are-assertions rule, the code should signal a type
;;; a bug reported and fixed by Alexey Dejneka sbcl-devel 2001-10-05:
;;; The type declarations should apply, hence under Python's
;;; declarations-are-assertions rule, the code should signal a type
;;; bug 103, reported by Arthur Lemmens sbcl-devel 2001-05-05,
;;; fixed by Alexey Dejneka patch sbcl-devel 2001-10-05:
;;; bug 103, reported by Arthur Lemmens sbcl-devel 2001-05-05,
;;; fixed by Alexey Dejneka patch sbcl-devel 2001-10-05:
;;; similar to gcl/ansi-test LOOP.1.27, and fixed at the same time:
(assert (equal (loop for x downto 7 by 2 from 13 collect x) '(13 11 9 7)))
;;; similar to gcl/ansi-test LOOP.1.27, and fixed at the same time:
(assert (equal (loop for x downto 7 by 2 from 13 collect x) '(13 11 9 7)))
(setf (gethash 'foo table) '(bar baz))
(assert (= (loop for nil being the hash-keys of table count t) 1))
(assert (equal (loop for nil being the hash-keys of table
(setf (gethash 'foo table) '(bar baz))
(assert (= (loop for nil being the hash-keys of table count t) 1))
(assert (equal (loop for nil being the hash-keys of table
(assert (= (loop for nil being the external-symbols of :cl count t) 978))
(assert (= (loop for x being the external-symbols of :cl count x) 977))
(assert (= (loop for nil being the external-symbols of :cl count t) 978))
(assert (= (loop for x being the external-symbols of :cl count x) 977))
- (ignore-errors (loop for i from 1 repeat 6.5 collect i))
- (ignore-errors (loop for i from 1 repeat (eval '6.5) collect i))))
+ (ignore-errors (loop for i from 1 repeat 6.5 collect i))
+ (ignore-errors (loop for i from 1 repeat (eval '6.5) collect i))))
(assert (= (loop with (a nil) = '(1 2) return a) 1))
(assert (= (loop with (nil a) = '(1 2) return a) 2))
(assert (= (loop with (a nil) = '(1 2) return a) 1))
(assert (= (loop with (nil a) = '(1 2) return a) 2))
(multiple-value-bind (result error)
(ignore-errors
(loop for i in '(1 2 3) always (< i 4) collect i))
(assert (null result))
(assert (typep error 'program-error)))
(assert (equal
(multiple-value-bind (result error)
(ignore-errors
(loop for i in '(1 2 3) always (< i 4) collect i))
(assert (null result))
(assert (typep error 'program-error)))
(assert (equal
(let ((ht (make-hash-table)))
(setf (gethash 1 ht) 3)
(setf (gethash 7 ht) 15)
(assert (= (loop for v fixnum being each hash-key in ht sum v) 8))
(assert (= (loop for v fixnum being each hash-value in ht sum v) 18))
(let ((ht (make-hash-table)))
(setf (gethash 1 ht) 3)
(setf (gethash 7 ht) 15)
(assert (= (loop for v fixnum being each hash-key in ht sum v) 8))
(assert (= (loop for v fixnum being each hash-value in ht sum v) 18))
(assert (raises-error? (loop for v float being each hash-value in ht sum v)
type-error)))
;; arithmetic indexes can be NIL or symbols.
(assert (equal (loop for nil from 0 to 2 collect nil)
(assert (raises-error? (loop for v float being each hash-value in ht sum v)
type-error)))
;; arithmetic indexes can be NIL or symbols.
(assert (equal (loop for nil from 0 to 2 collect nil)
;; although allowed by the loop syntax definition in 6.2/LOOP,
;; 6.1.2.1.1 says: "The variable var is bound to the value of form1 in
;; although allowed by the loop syntax definition in 6.2/LOOP,
;; 6.1.2.1.1 says: "The variable var is bound to the value of form1 in
(assert failure-p))
;; ...and another for indexes without FROM forms (these are treated
;; differently by the loop code right now
(multiple-value-bind (function warnings-p failure-p)
(compile nil
(assert failure-p))
;; ...and another for indexes without FROM forms (these are treated
;; differently by the loop code right now
(multiple-value-bind (function warnings-p failure-p)
(compile nil
- (compile nil '(lambda ()
- (declare (special x y))
- (loop thereis (pop x) thereis (pop y))))
- (warning (c) (error "Warned: ~S" c)))))
+ (compile nil '(lambda ()
+ (declare (special x y))
+ (loop thereis (pop x) thereis (pop y))))
+ (warning (c) (error "Warned: ~S" c)))))
;;; Detection of duplicate bindings, reported by Bruno Haible for CMUCL.
(multiple-value-bind (_ condition)
;;; Detection of duplicate bindings, reported by Bruno Haible for CMUCL.
(multiple-value-bind (_ condition)
(macroexpand '(LOOP WITH A = 0 FOR A DOWNFROM 10 TO 0 DO (PRINT A))))
(declare (ignore _))
(assert (typep condition 'program-error)))
(macroexpand '(LOOP WITH A = 0 FOR A DOWNFROM 10 TO 0 DO (PRINT A))))
(declare (ignore _))
(assert (typep condition 'program-error)))