This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

test-suite/tests/numbers.test


i'd like to contribute this file.

thi


---------------------------------
;;;; numbers.test --- test suite for Guile's numerical ops   -*- scheme -*-
;;;;
;;;; 	Copyright (C) 1999 Free Software Foundation, Inc.
;;;;
;;;; This program is free software; you can redistribute it and/or modify
;;;; it under the terms of the GNU General Public License as published by
;;;; the Free Software Foundation; either version 2, or (at your option)
;;;; any later version.
;;;;
;;;; This program is distributed in the hope that it will be useful,
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;;; GNU General Public License for more details.
;;;;
;;;; You should have received a copy of the GNU General Public License
;;;; along with this software; see the file COPYING.  If not, write to
;;;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
;;;; Boston, MA 02111-1307 USA

;;;; Commentary:

;;; Both R4RS and R5RS define these 54 numerical operations:
;;;
;;; * + - / < <= = > >= abs acos angle asin atan ceiling complex? cos
;;; denominator even? exact->inexact exact? exp expt floor gcd imag-part
;;; inexact->exact inexact? integer? lcm log magnitude make-polar
;;; make-rectangular max min modulo negative? number? numerator odd?
;;; positive? quotient rational? rationalize real-part real? remainder
;;; round sin sqrt tan truncate zero?
;;;
;;; You should probably put tests for these operations in the appropriate
;;; r?rs.test file.  This file has tests for numerical operations unique
;;; to Guile.

;;;; Code:

(use-modules (test-suite lib))

(defmacro pass-if-= (n exp)
  `(pass-if (string-append (with-output-to-string
                             (lambda () (write ',exp)))
                           " => "
                           (with-output-to-string
                             (lambda () (write ',n))))
            (= ,n ,exp)))

(pass-if-= 2 (ash 2 0))
(pass-if-= 4 (ash 2 1))
(pass-if-= 1 (ash 2 -1))

(pass-if-= 1 (ash 1 0))
(pass-if-= 2 (ash 1 1))
(pass-if-= 0 (ash 1 -1))

(pass-if-= 0 (ash 0 0))
(pass-if-= 0 (ash 0 1))
(pass-if-= 0 (ash 0 -1))

(pass-if-= -1 (ash -1 0))
(pass-if-= -2 (ash -1 1))
(pass-if-= -1 (ash -1 -1))

(pass-if-= -2 (ash -2 0))
(pass-if-= -4 (ash -2 1))
(pass-if-= -1 (ash -2 -1))

;;;; numbers.test ends here

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]