From 8218b146f881a0a53b3666a9bae5d1369bf82cce Mon Sep 17 00:00:00 2001 From: chetz Date: Thu, 12 Aug 2004 20:17:35 +0000 Subject: [PATCH] changed a few tests --- scsh/test/pattern-matching-test.scm | 13 +++++++------ scsh/test/read-delimited-strings.scm | 25 +++++++++++++++++++------ 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/scsh/test/pattern-matching-test.scm b/scsh/test/pattern-matching-test.scm index 4ab826f..5c0a392 100644 --- a/scsh/test/pattern-matching-test.scm +++ b/scsh/test/pattern-matching-test.scm @@ -46,13 +46,14 @@ (eq-match? (string-match (rx ("abcde")) test-string) (string-match (rx ("edcba")) test-string)))) -(add-test! 'null-match-by-any 'pattern-matching +(add-test! 'any-test 'pattern-matching ;; fails only because of the case i = 0 (lambda () - (string-match (rx any) nul-string))) - -(add-test! 'newline-match-by-any 'pattern-matching - (lambda () - (string-match (rx any) newln-string))) + (let loop ((i 0)) + (if (= 256 i) + #t + (if (string-match (rx any) (list->string (list (ascii->char i)))) + (loop (+ i 1)) + #f))))) (add-test! 'sequences-test 'pattern-matching (lambda () diff --git a/scsh/test/read-delimited-strings.scm b/scsh/test/read-delimited-strings.scm index 3def5fc..7e3dc2c 100644 --- a/scsh/test/read-delimited-strings.scm +++ b/scsh/test/read-delimited-strings.scm @@ -50,11 +50,11 @@ (read-line in-port 'concat)) (equal? "zeile 2\n" (read-line in-port 'concat)) - (equal? "zeile 3\n" + (equal? "zeile 3\004" (read-line in-port 'concat)))) - (make-string-input-port "zeile 1\nzeile 2\nzeile 3\n")))) ;; XXX klappt mit dem eof irgendwie nicht + (make-string-input-port "zeile 1\nzeile 2\nzeile 3\004")))) -(add-test! 'read-line-split-test 'reading-delimited-strings +(add-test! 'read-line-split-test 'reading-delimited-strings ;; XXX warum #\newline und nicht "\n"??? (lambda () ((lambda (in-port) (and (call-with-values (lambda () (read-line in-port 'split)) @@ -65,8 +65,8 @@ (equal? b #\newline)))) (call-with-values (lambda () (read-line in-port 'split)) (lambda (a b) (and (equal? a "zeile 3") - (equal? b #\newline)))))) - (make-string-input-port "zeile 1\nzeile 2\nzeile 3\n")))) ;; XXX vorhin ging's hier noch - jetzt nicht mehr (\#eof) + (equal? b "\004")))))) ;; XXX geht nicht mit "\004" und nicht mit (ascii->char 4)! + (make-string-input-port "zeile 1\nzeile 2\nzeile 3\004")))) (add-test! 'read-paragraph-test 'reading-delimited-strings (lambda () @@ -324,4 +324,17 @@ (lambda () (read-delimited char-digit? in-port 'split)) (lambda (a b) (and (equal? " nix\nzeile b1 x" a) (equal? #\2 b)))))) - (make-string-input-port "zeile a1 nix\nzeile b1 x2\nzeile c1 wieder nix\n")))) \ No newline at end of file + (make-string-input-port "zeile a1 nix\nzeile b1 x2\nzeile c1 wieder nix\n")))) + +;; =============================================================================================== + +(add-test! 'read-delimited!-with-char-set-test 'read-delimited-strings + (lambda () + (let ((buf " ")) + ((lambda (in-port) + (read-delimited! (list->char-set (list #\a #\b #\1)) + buf + in-port) + (equal? "zeile a " + buf)) + (make-string-input-port "zeile a1 nix\nzeile b1 x2\nzeile c1 wieder nix\n"))))) \ No newline at end of file