From 25a8e4f11ab029440b29a6ddb8429a9f9c096dc7 Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Tue, 17 May 2016 23:38:45 +0900 Subject: [PATCH] adding more srfi 130 tests --- lib/srfi/130/test.sld | 29 +++++++++-------------------- tests/lib-tests.scm | 2 ++ 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/lib/srfi/130/test.sld b/lib/srfi/130/test.sld index fbb507e6..349efdf0 100644 --- a/lib/srfi/130/test.sld +++ b/lib/srfi/130/test.sld @@ -10,6 +10,7 @@ (string-cursor->index str (apply string-index str pred o))) (define (string-index-right->index str pred . o) (string-cursor->index str (apply string-index-right str pred o))) + (define char-set:not-letter (char-set-complement char-set:letter)) (define (run-tests) (test-begin "srfi-130: cursor-based string library") @@ -126,23 +127,23 @@ (test "string-index #1" 4 (string-index->index "abcd:efgh:ijkl" (lambda (ch) (eqv? ch #\:)))) - ;; (test "string-index #2" 4 - ;; (string-index "abcd:efgh;ijkl" (char-set-complement char-set:letter))) + (test "string-index #2" 4 + (string-index->index "abcd:efgh;ijkl" (lambda (ch) (char-set-contains? char-set:not-letter ch)))) (test "string-index #3" 14 (string-index->index "abcd:efgh;ijkl" (lambda (ch) (char-set-contains? char-set:digit ch)))) (test "string-index #4" 9 (string-index->index "abcd:efgh:ijkl" (lambda (ch) (eqv? ch #\:)) 5)) (test "string-index-right #1" 5 (string-index-right->index "abcd:efgh;ijkl" (lambda (ch) (eqv? ch #\:)))) - ;; (test "string-index-right #2" 9 - ;; (string-index-right "abcd:efgh;ijkl" (char-set-complement char-set:letter))) + (test "string-index-right #2" 10 + (string-index-right->index "abcd:efgh;ijkl" (lambda (ch) (char-set-contains? char-set:not-letter ch)))) (test "string-index-right #3" 14 (string-index-right->index "abcd:efgh;ijkl" char-alphabetic?)) - ;; (test "string-index-right #4" 4 - ;; (string-index-right "abcd:efgh;ijkl" (char-set-complement char-set:letter) 2 5)) + (test "string-index-right #4" 10 + (string-index-right->index "abcd:efgh;ijkl" (lambda (ch) (char-set-contains? char-set:not-letter ch)) 7)) - ;; (test "string-count #1" 2 - ;; (string-count "abc def\tghi jkl" #\space)) + (test "string-count #1" 2 + (string-count "abc def\tghi jkl" (lambda (ch) (eqv? ch #\space)))) (test "string-count #2" 3 (string-count "abc def\tghi jkl" char-whitespace?)) (test "string-count #3" 2 @@ -307,18 +308,6 @@ (test "string-replace" "abcdhi" (string-replace "abcdefghi" "" 4 7)) - ;; (test "string-tokenize" '("Help" "make" "programs" "run," "run," "RUN!") - ;; (string-tokenize "Help make programs run, run, RUN!")) - ;; (test "string-tokenize" '("Help" "make" "programs" "run" "run" "RUN") - ;; (string-tokenize "Help make programs run, run, RUN!" - ;; char-set:letter)) - ;; (test "string-tokenize" '("programs" "run" "run" "RUN") - ;; (string-tokenize "Help make programs run, run, RUN!" - ;; char-set:letter 10)) - ;; (test "string-tokenize" '("elp" "make" "programs" "run" "run") - ;; (string-tokenize "Help make programs run, run, RUN!" - ;; char-set:lower-case)) - (test "string-filter" "rrrr" (string-filter (lambda (ch) (eqv? ch #\r)) "Help make programs run, run, RUN!")) diff --git a/tests/lib-tests.scm b/tests/lib-tests.scm index 7f6eb0a8..ce3e8303 100644 --- a/tests/lib-tests.scm +++ b/tests/lib-tests.scm @@ -11,6 +11,7 @@ (rename (srfi 69 test) (run-tests run-srfi-69-tests)) (rename (srfi 95 test) (run-tests run-srfi-95-tests)) (rename (srfi 99 test) (run-tests run-srfi-99-tests)) + (rename (srfi 130 test) (run-tests run-srfi-130-tests)) (rename (chibi base64-test) (run-tests run-base64-tests)) (rename (chibi crypto md5-test) (run-tests run-md5-tests)) (rename (chibi crypto rsa-test) (run-tests run-rsa-tests)) @@ -52,6 +53,7 @@ (run-srfi-69-tests) (run-srfi-95-tests) (run-srfi-99-tests) +(run-srfi-130-tests) (run-base64-tests) (run-doc-tests) (run-generic-tests)