1 ;;;; arithmetic tests with no side effects
3 ;;;; This software is part of the SBCL system. See the README file for
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
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.
14 (cl:in-package :cl-user)
16 ;;; Once upon a time, in the process of porting CMUCL's SPARC backend
17 ;;; to SBCL, multiplications were excitingly broken. While it's
18 ;;; unlikely that anything with such fundamental arithmetic errors as
19 ;;; these are going to get this far, it's probably worth checking.
20 (macrolet ((test (op res1 res2)
22 (assert (= (,op 4 2) ,res1))
23 (assert (= (,op 2 4) ,res2))
24 (assert (= (funcall (compile nil (lambda (x y) (,op x y))) 4 2)
26 (assert (= (funcall (compile nil (lambda (x y) (,op x y))) 2 4)
34 ;;; In a bug reported by Wolfhard Buss on cmucl-imp 2002-06-18 (BUG
35 ;;; 184), sbcl didn't catch all divisions by zero, notably divisions
36 ;;; of bignums and ratios by 0. Fixed in sbcl-0.7.6.13.
37 (macrolet ((test (form) `(multiple-value-bind (val cond)
40 (assert (typep cond 'division-by-zero)))))
42 (test (/ (1+ most-positive-fixnum) 0)))
44 ;;; In a bug reported by Raymond Toy on cmucl-imp 2002-07-18, (COERCE
45 ;;; <RATIONAL> '(COMPLEX FLOAT)) was failing to return a complex
46 ;;; float; a patch was given by Wolfhard Buss cmucl-imp 2002-07-19.
47 (assert (= (coerce 1 '(complex float)) #c(1.0 0.0)))
48 (assert (= (coerce 1/2 '(complex float)) #c(0.5 0.0)))
49 (assert (= (coerce 1.0d0 '(complex float)) #c(1.0d0 0.0d0)))