remove bigfloat support to avoid bug in v.5.3.x
parent
21308f2855
commit
589305ee09
@ -1,202 +1,199 @@
|
|||||||
#lang racket
|
#lang racket
|
||||||
;;; describe-test.rkt
|
;;; describe-test.rkt
|
||||||
;;; Copyright (c) 2009-2010 M. Douglas Williams
|
;;; Copyright (c) 2009-2010 M. Douglas Williams
|
||||||
;;;
|
;;;
|
||||||
;;; This program is free software: you can redistribute it and/or modify
|
;;; 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
|
;;; it under the terms of the GNU General Public License as published by
|
||||||
;;; the Free Software Foundation, either version 3 of the License, or
|
;;; the Free Software Foundation, either version 3 of the License, or
|
||||||
;;; (at your option) any later version.
|
;;; (at your option) any later version.
|
||||||
;;;
|
;;;
|
||||||
;;; This program is distributed in the hope that it will be useful,
|
;;; This program is distributed in the hope that it will be useful,
|
||||||
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
;;; GNU General Public License for more details.
|
;;; GNU General Public License for more details.
|
||||||
;;;
|
;;;
|
||||||
;;; You should have received a copy of the GNU General Public License
|
;;; You should have received a copy of the GNU General Public License
|
||||||
;;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
;;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
;;;
|
;;;
|
||||||
|
|
||||||
(require math/bigfloat
|
(require racket/mpair)
|
||||||
racket/mpair)
|
(require (planet williams/describe/describe))
|
||||||
(require (planet williams/describe/describe))
|
|
||||||
|
;;; Booleans
|
||||||
;;; Booleans
|
(printf "~n--- Booleans ---~n")
|
||||||
(printf "~n--- Booleans ---~n")
|
(describe #t)
|
||||||
(describe #t)
|
(describe #f)
|
||||||
(describe #f)
|
|
||||||
|
;;; Numbers
|
||||||
;;; Numbers
|
(printf "~n--- Numbers ---~n")
|
||||||
(printf "~n--- Numbers ---~n")
|
|
||||||
|
(define (! n)
|
||||||
(define (! n)
|
(if (= n 0)
|
||||||
(if (= n 0)
|
1
|
||||||
1
|
(* n (! (sub1 n)))))
|
||||||
(* n (! (sub1 n)))))
|
|
||||||
|
(describe +inf.0)
|
||||||
(describe +inf.0)
|
(describe -inf.0)
|
||||||
(describe -inf.0)
|
(describe +nan.0)
|
||||||
(describe +nan.0)
|
|
||||||
|
(describe 0)
|
||||||
(describe 0)
|
(describe (! 10))
|
||||||
(describe (! 10))
|
(describe (! 40))
|
||||||
(describe (! 40))
|
(describe (- (! 40) (! 41)))
|
||||||
(describe (- (! 40) (! 41)))
|
(describe (! 100))
|
||||||
(describe (! 100))
|
(describe (/ (! 10) (add1 (! 11))))
|
||||||
(describe (/ (! 10) (add1 (! 11))))
|
(describe -1+3i)
|
||||||
(describe -1+3i)
|
|
||||||
|
(describe 0.0)
|
||||||
(describe 0.0)
|
(describe 0.1e0)
|
||||||
(describe 0.1e0)
|
(describe 0.1f0)
|
||||||
(describe 0.1f0)
|
(describe 0.1t0)
|
||||||
(describe 0.1t0)
|
(describe (* (! 10) 1.0))
|
||||||
(describe (* (! 10) 1.0))
|
(describe 6.0221313e23)
|
||||||
(describe 6.0221313e23)
|
(describe 6.0221313f23)
|
||||||
(describe 6.0221313f23)
|
(describe 6.0221313t23)
|
||||||
(describe 6.0221313t23)
|
(describe (exact->inexact (! 40)))
|
||||||
(describe (exact->inexact (! 40)))
|
(describe (sqrt 10))
|
||||||
(describe (sqrt 10))
|
(describe (sqrt -10))
|
||||||
(describe (sqrt -10))
|
(describe (+ (sqrt 10) (sqrt -10)))
|
||||||
(describe (+ (sqrt 10) (sqrt -10)))
|
|
||||||
|
|
||||||
(describe (bf 1/10))
|
;;; Strings
|
||||||
(describe (bf "15e200000000"))
|
|
||||||
|
(printf "~n--- Strings ---~n")
|
||||||
;;; Strings
|
(describe "abc")
|
||||||
|
(describe (string #\1 #\2 #\3))
|
||||||
(printf "~n--- Strings ---~n")
|
|
||||||
(describe "abc")
|
;;; Byte Strings
|
||||||
(describe (string #\1 #\2 #\3))
|
|
||||||
|
(printf "~n--- Byte Strings ---~n")
|
||||||
;;; Byte Strings
|
(describe #"abc")
|
||||||
|
(describe (bytes 48 49 50))
|
||||||
(printf "~n--- Byte Strings ---~n")
|
|
||||||
(describe #"abc")
|
;;; Characters
|
||||||
(describe (bytes 48 49 50))
|
|
||||||
|
(printf "~n--- Characters ---~n")
|
||||||
;;; Characters
|
(describe #\a)
|
||||||
|
(describe #\A)
|
||||||
(printf "~n--- Characters ---~n")
|
(describe #\0)
|
||||||
(describe #\a)
|
(describe #\()
|
||||||
(describe #\A)
|
|
||||||
(describe #\0)
|
;;; Symbols
|
||||||
(describe #\()
|
|
||||||
|
(printf "~n--- Symbols ---~n")
|
||||||
;;; Symbols
|
(describe 'abc)
|
||||||
|
(describe '|(a + b)|)
|
||||||
(printf "~n--- Symbols ---~n")
|
(describe (gensym))
|
||||||
(describe 'abc)
|
|
||||||
(describe '|(a + b)|)
|
;;; Regular Expressions
|
||||||
(describe (gensym))
|
|
||||||
|
(printf "~n--- Regular Expressions ---~n")
|
||||||
;;; Regular Expressions
|
(describe #rx"Ap*le")
|
||||||
|
(describe #px"Ap*le")
|
||||||
(printf "~n--- Regular Expressions ---~n")
|
|
||||||
(describe #rx"Ap*le")
|
;;; Byte Regular Expressions
|
||||||
(describe #px"Ap*le")
|
|
||||||
|
(printf "~n--- Byte Regular Expressions ---~n")
|
||||||
;;; Byte Regular Expressions
|
(describe #rx#"Ap*le")
|
||||||
|
(describe #px#"Ap*le")
|
||||||
(printf "~n--- Byte Regular Expressions ---~n")
|
|
||||||
(describe #rx#"Ap*le")
|
;;; Keywords
|
||||||
(describe #px#"Ap*le")
|
|
||||||
|
(printf "~n--- Keywords ---~n")
|
||||||
;;; Keywords
|
(describe '#:key)
|
||||||
|
|
||||||
(printf "~n--- Keywords ---~n")
|
;;; Lists and Pairs
|
||||||
(describe '#:key)
|
|
||||||
|
(printf "~n--- Lists and Pairs ---~n")
|
||||||
;;; Lists and Pairs
|
(describe '(this is a proper list))
|
||||||
|
(describe '(this is an improper . list))
|
||||||
(printf "~n--- Lists and Pairs ---~n")
|
(describe (list '(this . is) '(also . a) '(proper . list)))
|
||||||
(describe '(this is a proper list))
|
|
||||||
(describe '(this is an improper . list))
|
;;; Mutable Lists and Pairs
|
||||||
(describe (list '(this . is) '(also . a) '(proper . list)))
|
|
||||||
|
(printf "~n--- Mutable Lists and Pairs ---~n")
|
||||||
;;; Mutable Lists and Pairs
|
(describe (mlist 'this 'is 'a 'proper 'list))
|
||||||
|
(describe (mcons 'this (mcons 'is (mcons 'an (mcons 'improper 'list)))))
|
||||||
(printf "~n--- Mutable Lists and Pairs ---~n")
|
(describe (mlist '(this . is) '(also . a) '(proper . list)))
|
||||||
(describe (mlist 'this 'is 'a 'proper 'list))
|
|
||||||
(describe (mcons 'this (mcons 'is (mcons 'an (mcons 'improper 'list)))))
|
;;; Vectors
|
||||||
(describe (mlist '(this . is) '(also . a) '(proper . list)))
|
|
||||||
|
(printf "~n--- Vectors ---~n")
|
||||||
;;; Vectors
|
(describe #(1 2 3))
|
||||||
|
|
||||||
(printf "~n--- Vectors ---~n")
|
;;; Boxes
|
||||||
(describe #(1 2 3))
|
|
||||||
|
(printf "~n--- Boxes ---~n")
|
||||||
;;; Boxes
|
(describe (box 12))
|
||||||
|
(describe (box (box 'a)))
|
||||||
(printf "~n--- Boxes ---~n")
|
(describe (box (sqrt 10)))
|
||||||
(describe (box 12))
|
|
||||||
(describe (box (box 'a)))
|
;;; Weak Boxes
|
||||||
(describe (box (sqrt 10)))
|
|
||||||
|
(printf "~n--- Weak Boxes ---~n")
|
||||||
;;; Weak Boxes
|
(describe (make-weak-box 12))
|
||||||
|
(describe (make-weak-box (make-weak-box 'a)))
|
||||||
(printf "~n--- Weak Boxes ---~n")
|
(describe (make-weak-box (sqrt 10)))
|
||||||
(describe (make-weak-box 12))
|
|
||||||
(describe (make-weak-box (make-weak-box 'a)))
|
;;; Hashes
|
||||||
(describe (make-weak-box (sqrt 10)))
|
|
||||||
|
(printf "~n--- Hashes ---~n")
|
||||||
;;; Hashes
|
(describe #hash((a . 12) (b . 14) (c . 16)))
|
||||||
|
(describe #hasheq((a . a) (b . b) (c . c)))
|
||||||
(printf "~n--- Hashes ---~n")
|
(describe #hasheqv((a . #\a) (b . #\b) (c . #\c)))
|
||||||
(describe #hash((a . 12) (b . 14) (c . 16)))
|
|
||||||
(describe #hasheq((a . a) (b . b) (c . c)))
|
(define ht (make-hash))
|
||||||
(describe #hasheqv((a . #\a) (b . #\b) (c . #\c)))
|
(hash-set! ht 'a 12)
|
||||||
|
(hash-set! ht 'b 14)
|
||||||
(define ht (make-hash))
|
(hash-set! ht 'c 16)
|
||||||
(hash-set! ht 'a 12)
|
(describe ht)
|
||||||
(hash-set! ht 'b 14)
|
|
||||||
(hash-set! ht 'c 16)
|
(define wht (make-weak-hash))
|
||||||
(describe ht)
|
(hash-set! wht 'a 12)
|
||||||
|
(hash-set! wht 'b 14)
|
||||||
(define wht (make-weak-hash))
|
(hash-set! wht 'c 16)
|
||||||
(hash-set! wht 'a 12)
|
(describe wht)
|
||||||
(hash-set! wht 'b 14)
|
|
||||||
(hash-set! wht 'c 16)
|
;;; Procedures
|
||||||
(describe wht)
|
|
||||||
|
(printf "~n--- Procedures ---~n")
|
||||||
;;; Procedures
|
(describe car)
|
||||||
|
(describe open-output-file)
|
||||||
(printf "~n--- Procedures ---~n")
|
(describe current-input-port)
|
||||||
(describe car)
|
(describe (lambda (x) x))
|
||||||
(describe open-output-file)
|
|
||||||
(describe current-input-port)
|
;;; Ports
|
||||||
(describe (lambda (x) x))
|
|
||||||
|
(printf "~n--- Ports ---~n")
|
||||||
;;; Ports
|
(describe (current-input-port))
|
||||||
|
(describe (current-output-port))
|
||||||
(printf "~n--- Ports ---~n")
|
|
||||||
(describe (current-input-port))
|
;;; Void
|
||||||
(describe (current-output-port))
|
|
||||||
|
(printf "~n--- Void ---~n")
|
||||||
;;; Void
|
(describe (void))
|
||||||
|
|
||||||
(printf "~n--- Void ---~n")
|
;;; EOF
|
||||||
(describe (void))
|
|
||||||
|
(printf "~n--- EOF ---~n")
|
||||||
;;; EOF
|
(describe eof)
|
||||||
|
|
||||||
(printf "~n--- EOF ---~n")
|
;;; Paths
|
||||||
(describe eof)
|
|
||||||
|
(printf "~n--- Paths ---~n")
|
||||||
;;; Paths
|
(describe (string->path "C:\\Program-files\\PLT"))
|
||||||
|
(describe (string->path "../dir/file.ext"))
|
||||||
(printf "~n--- Paths ---~n")
|
|
||||||
(describe (string->path "C:\\Program-files\\PLT"))
|
;;; Structures
|
||||||
(describe (string->path "../dir/file.ext"))
|
|
||||||
|
(printf "~n--- Structures ---~n")
|
||||||
;;; Structures
|
(define-struct transparent-struct (a b c) #:transparent)
|
||||||
|
(define ts-1 (make-transparent-struct 'a 'b 'c))
|
||||||
(printf "~n--- Structures ---~n")
|
(describe ts-1)
|
||||||
(define-struct transparent-struct (a b c) #:transparent)
|
|
||||||
(define ts-1 (make-transparent-struct 'a 'b 'c))
|
;;; Other Named Things (I.E., Opaque Structures)
|
||||||
(describe ts-1)
|
|
||||||
|
(printf "~n--- Other Named Things ---~n")
|
||||||
;;; Other Named Things (I.E., Opaque Structures)
|
(define-struct opaque-struct (a b c))
|
||||||
|
(define os-1 (make-opaque-struct 'a 'b 'c))
|
||||||
(printf "~n--- Other Named Things ---~n")
|
(describe os-1)
|
||||||
(define-struct opaque-struct (a b c))
|
|
||||||
(define os-1 (make-opaque-struct 'a 'b 'c))
|
|
||||||
(describe os-1)
|
|
||||||
|
@ -1,39 +0,0 @@
|
|||||||
#lang racket
|
|
||||||
|
|
||||||
(require math/bigfloat)
|
|
||||||
(require (planet williams/describe/describe))
|
|
||||||
|
|
||||||
(printf "--- Using literals (big float) ---~n")
|
|
||||||
(describe (bf 1/10))
|
|
||||||
(describe (bf 2/10))
|
|
||||||
(describe (bf 3/10))
|
|
||||||
(describe (bf 4/10))
|
|
||||||
(describe (bf 5/10))
|
|
||||||
(describe (bf 6/10))
|
|
||||||
(describe (bf 7/10))
|
|
||||||
(describe (bf 8/10))
|
|
||||||
(describe (bf 9/10))
|
|
||||||
(describe (bf 10/10))
|
|
||||||
|
|
||||||
(printf "--- Exact decimal values of big floats ---~n")
|
|
||||||
(float->string (bf 1/10))
|
|
||||||
(float->string (bf 2/10))
|
|
||||||
(float->string (bf 3/10))
|
|
||||||
(float->string (bf 4/10))
|
|
||||||
(float->string (bf 5/10))
|
|
||||||
(float->string (bf 6/10))
|
|
||||||
(float->string (bf 7/10))
|
|
||||||
(float->string (bf 8/10))
|
|
||||||
(float->string (bf 9/10))
|
|
||||||
(float->string (bf 10/10))
|
|
||||||
|
|
||||||
(printf "--- Using summation (big float) ---~n")
|
|
||||||
(for/fold ((sum 0.bf))
|
|
||||||
((i (in-range 10)))
|
|
||||||
(define new-sum (bf+ sum (bf 1/10)))
|
|
||||||
(describe new-sum)
|
|
||||||
new-sum)
|
|
||||||
|
|
||||||
(printf "--- Using product (big float) ---~n")
|
|
||||||
(for ((i (in-range 1 11)))
|
|
||||||
(describe (bf* (bf i) (bf 1/10))))
|
|
Loading…
Reference in New Issue