add test for regexp

This commit is contained in:
Sunrim KIM (keen) 2014-07-22 21:34:23 +09:00
parent 5f30b37fd9
commit 561cfc9816
2 changed files with 14 additions and 0 deletions

View File

@ -13,4 +13,6 @@ if (REGEX_FOUND)
list(APPEND PICRIN_CONTRIB_INITS regexp)
list(APPEND PICRIN_CONTRIB_LIBRARIES ${REGEX_LIBRARIES})
list(APPEND PICRIN_CONTRIB_SOURCES ${PICRIN_REGEX_SOURCES})
add_custom_target(test-regexp for test in ${PROJECT_SOURCE_DIR}/contrib/10.regexp/t/*.scm \; do bin/picrin "$$test" \; done DEPENDS repl)
set(CONTRIB_TESTS ${CONTRIB_TESTS} test-regexp)
endif()

View File

@ -0,0 +1,12 @@
(import (scheme base)
(picrin test)
(picrin regexp))
(test #t (regexp? (regexp "simple")))
(test #f (regexp? "it\\s[s]e+ms\\s(reg)?exp"))
(test-values (values '("abcd" "b") '(5 6)) (regexp-match (regexp "a(b)cd") "abdacabcd"))
(test '("a" "b" "c" "d") (regexp-split (regexp ",") "a,b,c,d"))
(test '("a" "b" "c" "d") (regexp-split (regexp "\\.+") "a.b....c.....d"))
(test "a b c d" (regexp-replace (regexp ",") " " "a,b,c,d"))
(test "newline tab spase " (regexp-replace (regexp "\\s") " " "newline
tab space "))