diff --git a/collects/tests/mzscheme/all.ss b/collects/tests/mzscheme/all.ss index a1f4bf6977..e6f19c4b5b 100644 --- a/collects/tests/mzscheme/all.ss +++ b/collects/tests/mzscheme/all.ss @@ -1,5 +1,6 @@ (load-relative "loadtest.ss") +(load-relative "scheme.ss") (load-relative "mz.ss") (load-relative "mzlib.ss") (load-in-sandbox "boundmap-test.ss") diff --git a/collects/tests/mzscheme/contract-mzlib-test.ss b/collects/tests/mzscheme/contract-mzlib-test.ss index 767baf0f0f..e55bfbd7c2 100644 --- a/collects/tests/mzscheme/contract-mzlib-test.ss +++ b/collects/tests/mzscheme/contract-mzlib-test.ss @@ -7,7 +7,7 @@ of the contract library does not change over time. |# (load-relative "loadtest.ss") -(Section 'contract) +(Section 'mzlib/contract) (parameterize ([error-print-width 200]) (let () diff --git a/collects/tests/mzscheme/for.ss b/collects/tests/mzscheme/for.ss index 3992af232b..ac423688bd 100644 --- a/collects/tests/mzscheme/for.ss +++ b/collects/tests/mzscheme/for.ss @@ -1,9 +1,7 @@ (load-relative "loadtest.ss") -(require mzlib/for) - -(Section 'generator) +(Section 'for) (define-syntax (test-multi-generator stx) (syntax-case stx () diff --git a/collects/tests/mzscheme/function.ss b/collects/tests/mzscheme/function.ss index a2cd6a3c96..54cee0681a 100644 --- a/collects/tests/mzscheme/function.ss +++ b/collects/tests/mzscheme/function.ss @@ -6,24 +6,6 @@ (require mzlib/list) (require mzlib/etc) -(test (list 1 2 3 4) foldl cons '() (list 4 3 2 1)) -(test (list 1 2 3 4) foldr cons '() (list 1 2 3 4)) -(test - (list (list 5 6) (list 3 4) (list 1 2)) - foldl (lambda (x y sofar) (cons (list x y) sofar)) - '() - (list 1 3 5) - (list 2 4 6)) -(test - (list (list 1 2) (list 3 4) (list 5 6)) - foldr (lambda (x y sofar) (cons (list x y) sofar)) - '() - (list 1 3 5) - (list 2 4 6)) - -(arity-test foldl 3 -1) -(arity-test foldr 3 -1) - (test 0 (compose add1 sub1) 0) (test 2 (compose add1 (lambda () 1))) (test 5 (compose (lambda (a b) a) (lambda (x) (values (add1 x) x))) 4) @@ -43,25 +25,6 @@ (arity-test compose 1 -1) -(test '(1 2 3) filter number? '(1 a 2 b 3 c d)) -(test '() filter string? '(1 a 2 b 3 c d)) -(err/rt-test (filter string? '(1 2 3 . 4)) exn:application:mismatch?) -(err/rt-test (filter 2 '(1 2 3))) -(err/rt-test (filter cons '(1 2 3))) -(arity-test filter 2 2) - -(test '(0 1 2) memf add1 '(0 1 2)) -(test '(2 (c 17)) memf number? '((a 1) (0 x) (1 w) 2 (c 17))) -(test '("ok" (2 .7) c) memf string? '((a 0) (0 a) (1 w) "ok" (2 .7) c)) -(err/rt-test (memf cons '((1) (2) (3)))) -(err/rt-test (memf string? '((1) (2) (3) . 4)) exn:application:mismatch?) - -(err/rt-test (assf add1 '(0 1 2)) exn:application:mismatch?) -(test '(0 x) assf number? '((a 1) (0 x) (1 w) (2 r) (c 17))) -(test '("ok" . 10) assf string? '((a 0) (0 a) (1 w) ("ok" . 10) (2 .7) c)) -(err/rt-test (assf cons '((1) (2) (3)))) -(err/rt-test (assf string? '((1) (2) (3) . 4)) exn:application:mismatch?) - (test '("a" "b" "c" "c" "d" "e" "f") sort '("d" "f" "e" "c" "a" "c" "b") @@ -108,12 +71,6 @@ ((0 2) (1 1) (0 3)) ((0 2) (0 3) (1 1))))) -(let ([s (let loop ([n 1000]) - (if (zero? n) - '() - (cons (random 1000) (loop (sub1 n)))))]) - (test (quicksort s <) mergesort s <)) - (test 3 (rec f (λ (x) 3)) 3) (test 3 (rec f (λ (x) x)) 3) (test 2 (rec f (λ (x) (if (= x 3) (f 2) x))) 3) diff --git a/collects/tests/mzscheme/list.ss b/collects/tests/mzscheme/list.ss new file mode 100644 index 0000000000..38d8ac4704 --- /dev/null +++ b/collects/tests/mzscheme/list.ss @@ -0,0 +1,101 @@ + +(load-relative "loadtest.ss") + +(Section 'list) + +(require scheme/list) + +(test (list 1 2 3 4) foldl cons '() (list 4 3 2 1)) +(test (list 1 2 3 4) foldr cons '() (list 1 2 3 4)) +(test (list (list 5 6) (list 3 4) (list 1 2)) + foldl (lambda (x y sofar) (cons (list x y) sofar)) + '() + (list 1 3 5) + (list 2 4 6)) +(test (list (list 1 2) (list 3 4) (list 5 6)) + foldr (lambda (x y sofar) (cons (list x y) sofar)) + '() + (list 1 3 5) + (list 2 4 6)) + +(arity-test foldl 3 -1) +(arity-test foldr 3 -1) + +(test '(1 2 3) filter number? '(1 a 2 b 3 c d)) +(test '() filter string? '(1 a 2 b 3 c d)) +(err/rt-test (filter string? '(1 2 3 . 4)) exn:application:mismatch?) +(err/rt-test (filter 2 '(1 2 3))) +(err/rt-test (filter cons '(1 2 3))) +(arity-test filter 2 2) + +(test '(0 1 2) memf add1 '(0 1 2)) +(test '(2 (c 17)) memf number? '((a 1) (0 x) (1 w) 2 (c 17))) +(test '("ok" (2 .7) c) memf string? '((a 0) (0 a) (1 w) "ok" (2 .7) c)) +(err/rt-test (memf cons '((1) (2) (3)))) +(err/rt-test (memf string? '((1) (2) (3) . 4)) exn:application:mismatch?) + +(err/rt-test (assf add1 '(0 1 2)) exn:application:mismatch?) +(test '(0 x) assf number? '((a 1) (0 x) (1 w) (2 r) (c 17))) +(test '("ok" . 10) assf string? '((a 0) (0 a) (1 w) ("ok" . 10) (2 .7) c)) +(err/rt-test (assf cons '((1) (2) (3)))) +(err/rt-test (assf string? '((1) (2) (3) . 4)) exn:application:mismatch?) + +;; ---------- sort ---------- +(test '("a" "b" "c" "c" "d" "e" "f") + sort + '("d" "f" "e" "c" "a" "c" "b") + string