mes/tests/math.test
Jan Nieuwenhuizen 99718a8b7a
core: Fixes for int-max, int-min.
* src/math.c (greater_p): Fix INT_MAX > 0.
  (less_p): Fix INT_MIN < 0.
* tests/math.test ("< INT-MIN"): Test it.
  ("< INT-MAX"):
  ("> INT-MAX"):
  ("> INT-MAX 0"):
  ("> INT-MIN"):
* tests/srfi-13.test ("string->number INT-MAX"): Test it.
  ("string->number INT-MIN"):
  ("number->string INT-MAX"):
  ("number->string INT-MIN"):
* scaffold/tests/60-math.c (test): Test it.
2018-05-02 23:11:27 +02:00

90 lines
2.3 KiB
Scheme
Executable file

#! /bin/sh
# -*-scheme-*-
MES=${MES-$(dirname $0)/../src/mes}
$MES -s $0
exit $?
!#
;;; -*-scheme-*-
;;; Mes --- Maxwell Equations of Software
;;; Copyright © 2016 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
;;;
;;; This file is part of Mes.
;;;
;;; Mes 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 3 of the License, or (at
;;; your option) any later version.
;;;
;;; Mes 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 Mes. If not, see <http://www.gnu.org/licenses/>.
(mes-use-module (mes scm))
(mes-use-module (srfi srfi-0))
(mes-use-module (mes test))
(pass-if-equal "+" 6 (+ 1 2 3))
(pass-if-equal "*" 27 (* 3 3 3))
(pass-if-equal "/" 3 (/ 9 3))
(pass-if-equal "remainder" 2 (remainder 11 3))
(pass-if-equal "modulo" 2 (modulo 11 3))
(pass-if-equal "expt" 8 (expt 2 3))
(pass-if-equal "logior" 7 (logior 0 1 2 4))
(pass-if-equal "ash"
8 (ash 1 3))
(pass-if-equal "ash -1"
5 (ash 10 -1))
(pass-if-equal "=" 3 '3)
(pass-if "= 2" (not (= 3 '4)))
(pass-if "=" (=))
(pass-if "= 1" (= 0))
(pass-if "= 2" (= 0 0))
(pass-if "= 3" (= 0 0))
(pass-if-not "= 4" (= 0 1 0))
(pass-if "<" (<))
(pass-if "< 1" (< 0))
(pass-if "< 2" (< 0 1))
(pass-if-not "< 3" (< 1 0))
(pass-if "< 4" (< 0 1 2))
(pass-if-not "< 5" (< 0 2 1))
(pass-if "< INT-MIN" (< -2147483648))
(pass-if "< INT-MIN" (< -2147483648 0))
(pass-if "< INT-MAX" (< 2147483647))
(pass-if ">" (>))
(pass-if "> 1" (> 0))
(pass-if "> 2" (> 1 0))
(pass-if-not "> 3" (> 0 1))
(pass-if "> 4" (> 2 1 0))
(pass-if-not "> 5" (> 1 2 0))
(pass-if "> INT-MAX" (> 2147483647))
(pass-if "> INT-MAX 0" (> 2147483647 0))
(pass-if "> INT-MIN" (> -2147483648))
(pass-if ">=" (>= 3 2 1))
(pass-if-not ">= 2" (>= 1 2 3))
(pass-if-not "<=" (<= 3 2 1))
(pass-if "<= 2" (<= 1 2 3))
(pass-if-equal "max" 0 (max 0))
(pass-if-equal "max 1" 1 (max 0 1))
(pass-if-equal "max 2" 2 (max 1 0 2))
(pass-if-equal "min" 0 (min 0))
(pass-if-equal "min 1" 0 (min 0 1))
(pass-if-equal "min 2" 0 (min 1 0 2))
(pass-if-equal "#x-10" -16 #x-10)
(result 'report)