From: Taylor R Campbell Date: Fri, 16 Nov 2018 07:22:25 +0000 (+0000) Subject: Add some trivial string->number tests. X-Git-Tag: mit-scheme-pucked-10.1.2~16^2~83 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=671fb38429a3c3dd1ee246bd85e97fb35a315ce1;p=mit-scheme.git Add some trivial string->number tests. --- diff --git a/tests/check.scm b/tests/check.scm index d9f78abd8..2b86645af 100644 --- a/tests/check.scm +++ b/tests/check.scm @@ -72,6 +72,7 @@ USA. ("runtime/test-library-loader" (runtime library)) "runtime/test-md5" "runtime/test-mime-codec" + "runtime/test-numpar" ("runtime/test-parametric-predicate" (runtime parametric-predicate)) "runtime/test-predicate" ("runtime/test-predicate-dispatch" (runtime predicate-dispatch)) diff --git a/tests/runtime/test-numpar.scm b/tests/runtime/test-numpar.scm new file mode 100644 index 000000000..7f4ec83c6 --- /dev/null +++ b/tests/runtime/test-numpar.scm @@ -0,0 +1,86 @@ +#| -*-Scheme-*- + +Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, + 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, + 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, + 2017, 2018 Massachusetts Institute of Technology + +This file is part of MIT/GNU Scheme. + +MIT/GNU Scheme 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 of the License, or (at +your option) any later version. + +MIT/GNU Scheme 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 MIT/GNU Scheme; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, +USA. + +|# + +;;;; Tests of number parser + +(declare (usual-integrations)) + +(define (define-eqv-test s v #!optional xfail?) + (define-eqv-test-1 s v xfail?) + (if (not (string=? s (string-upcase s))) + (define-eqv-test-1 (string-upcase s) v xfail?))) + +(define (define-eqv-test-1 s v #!optional xfail?) + (define-test s + (lambda () + (with-xfail xfail? + (lambda () + (assert-eqv (string->number s) v)))))) + +(define (with-xfail xfail? body) + (case xfail? + ((xfail) (expect-failure body)) + ((xerror) (assert-error body)) + (else (body)))) + +(define-eqv-test "#e1e9" (expt 10 9)) +(define-eqv-test "#e1f9" (expt 10 9)) +(define-eqv-test "#e1s9" (expt 10 9)) +(define-eqv-test "#e1l9" (expt 10 9)) +(define-eqv-test "#e1e-9" (expt 10 -9)) +(define-eqv-test "#e1f-9" (expt 10 -9)) +(define-eqv-test "#e1s-9" (expt 10 -9)) +(define-eqv-test "#e1l-9" (expt 10 -9)) +(define-eqv-test "#e1.1e1" 11) +(define-eqv-test "#b1000000000000000000000000000000000000000000000000000000000000000" (expt 2 63)) +(define-eqv-test "#o1000000000000000000000000000000000000000000000000000000000000000" (expt 8 63)) +(define-eqv-test "#x1000000000000000000000000000000000000000000000000000000000000000" (expt 16 63)) +(define-eqv-test "0." (int:->flonum 0)) +(define-eqv-test "-0." (flo:negate (int:->flonum 0))) +(define-eqv-test "#b100" 4) +(define-eqv-test "#o100" 64) +(define-eqv-test "#d100" 100) +(define-eqv-test "#x100" 256) +(define-eqv-test "#e#b100" 4) +(define-eqv-test "#e#o100" 64) +(define-eqv-test "#e#d100" 100) +(define-eqv-test "#e#x100" 256) +(define-eqv-test "#b#e100" 4) +(define-eqv-test "#o#e100" 64) +(define-eqv-test "#d#e100" 100) +(define-eqv-test "#x#e100" 256) +(define-eqv-test "#b-100" -4) +(define-eqv-test "#o-100" -64) +(define-eqv-test "#d-100" -100) +(define-eqv-test "#x-100" -256) +(define-eqv-test "#e#b-100" -4) +(define-eqv-test "#e#o-100" -64) +(define-eqv-test "#e#d-100" -100) +(define-eqv-test "#e#x-100" -256) +(define-eqv-test "#b#e-100" -4) +(define-eqv-test "#o#e-100" -64) +(define-eqv-test "#d#e-100" -100) +(define-eqv-test "#x#e-100" -256)