(require-library basic-sequences simple-tests arrays) (import basic-sequences simple-tests (only arrays array array? array-ref array-tail array->list)) (define-test (tagged-vectors?) (check (eq? ((thunk x:)) x:) (thunk? (thunk 1 2 3)) (define tv (tagged-vector x: 0 1 2 3)) (eq? (tagged-vector-ref tv 0) x:) (define null (tagged-vector x:)) (tagged-vector? null) (seq? null) (not (seq-null? null)) (define tv0 (tagged-vector-tail tv 0)) (define tv1 (tagged-vector-tail tv 1)) (define tv2 (tagged-vector-tail tv 2)) (define tv3 (tagged-vector-tail tv 3)) (eq? (tagged-vector-ref tv3 0) x:) (define tv4 (tagged-vector-tail tv 4)) (tagged-vector? tv4) (not (seq-null? tv4)) (define tv5 (tagged-vector-tail tv 5)) (seq-null? tv5) (not (condition-case (tagged-vector-ref tv5 0) ((exn sequence) #f))) )) (define-test (sequences?) (check (seq-db array? ref: array-ref tail: array-tail maker: array ra?: #t) (define lst '(0 1 2 3 4)) (define pls '(0 1 2 3 . 4)) (define vec #(0 1 2 3 4)) (define arr (array 0 1 2 3 4)) (define str "01234") (= (seq-ref lst 3) 3) (= (seq-ref pls 3) 3) (= (seq-tail pls 4) 4) (= (seq-ref vec 3) 3) (= (seq-ref arr 3) 3) (char=? (seq-ref str 3) #\3) (equal? (seq-tail lst 3) '(3 4)) (equal? (seq-tail pls 3) '(3 . 4)) (equal? (seq-tail vec 3) #(3 4)) (equal? (array->list (seq-tail arr 3)) '(3 4)) (string=? (seq-tail str 3) "34") (seq-null? (seq-tail lst 5)) (seq-null? (seq-tail vec 5)) (seq-null? (seq-tail arr 5)) (seq-null? (seq-tail str 5)) (seq-null? (seq-tail pls 4)) (seq? lst) (seq? pls) (seq? vec) (seq? str) (seq? arr) (not ((seq-of integer? odd?) arr)) ((seq-of integer? odd?) #(1 3 5 7)) (eq? (seq-maker lst) list) (eq? (seq-maker pls) cons*) (eq? (seq-maker vec) vector) (seq-random-access? arr) (seq-random-access? vec) (not (seq-random-access? lst)) (equal? (cons* 0 1 2 3) '(0 1 2 . 3)) )) (compound-test (SEQUNCES) (sequences?) (tagged-vectors?) )