From cdee9d91349ba53a23244d1f3ea5061c8c074975 Mon Sep 17 00:00:00 2001 From: "Sunrim KIM (keen)" <3han5chou7@gmail.com> Date: Sun, 20 Jul 2014 17:54:08 +0900 Subject: [PATCH 1/9] make contribs independant of the directory structure of picrin --- contrib/10.partcont/CMakeLists.txt | 2 +- contrib/10.pretty-print/CMakeLists.txt | 2 +- contrib/10.regexp/CMakeLists.txt | 5 ++++- {cmake => contrib/10.regexp/cmake}/FindREGEX.cmake | 0 contrib/10.regexp/t/test.scm | 11 +++++++++++ contrib/20.for/CMakeLists.txt | 2 +- contrib/CMakeLists.txt | 3 ++- 7 files changed, 20 insertions(+), 5 deletions(-) rename {cmake => contrib/10.regexp/cmake}/FindREGEX.cmake (100%) create mode 100644 contrib/10.regexp/t/test.scm diff --git a/contrib/10.partcont/CMakeLists.txt b/contrib/10.partcont/CMakeLists.txt index 65f16fb2..bedbbd75 100644 --- a/contrib/10.partcont/CMakeLists.txt +++ b/contrib/10.partcont/CMakeLists.txt @@ -1,2 +1,2 @@ -file(GLOB PARTCONT_FILES ${PROJECT_SOURCE_DIR}/contrib/10.partcont/piclib/*.scm) +file(GLOB PARTCONT_FILES ${PICRIN_CONTRIB_DIR}/10.partcont/piclib/*.scm) list(APPEND PICLIB_CONTRIB_LIBS ${PARTCONT_FILES}) diff --git a/contrib/10.pretty-print/CMakeLists.txt b/contrib/10.pretty-print/CMakeLists.txt index cf0327da..c5353018 100644 --- a/contrib/10.pretty-print/CMakeLists.txt +++ b/contrib/10.pretty-print/CMakeLists.txt @@ -1 +1 @@ -list(APPEND PICLIB_CONTRIB_LIBS ${PROJECT_SOURCE_DIR}/contrib/10.pretty-print/pretty-print.scm) +list(APPEND PICLIB_CONTRIB_LIBS ${PICRIN_CONTRIB_DIR}/10.pretty-print/pretty-print.scm) diff --git a/contrib/10.regexp/CMakeLists.txt b/contrib/10.regexp/CMakeLists.txt index 6ab06aaa..aa177aaa 100644 --- a/contrib/10.regexp/CMakeLists.txt +++ b/contrib/10.regexp/CMakeLists.txt @@ -1,11 +1,14 @@ # regex +set(PICRIN_REGEX_DIR ${PICRIN_CONTRIB_DIR}/10.regexp) +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PICRIN_REGEX_DIR}/cmake/") + find_package(REGEX) if (REGEX_FOUND) add_definitions(${REGEX_DEFINITIONS}) include_directories(${REGEX_INCLUDE_DIR}) - file(GLOB PICRIN_REGEX_SOURCES ${PROJECT_SOURCE_DIR}/contrib/10.regexp/src/*.c) + file(GLOB PICRIN_REGEX_SOURCES ${PICRIN_REGEX_DIR}/src/*.c) list(APPEND PICRIN_CONTRIB_INITS regexp) list(APPEND PICRIN_CONTRIB_LIBRARIES ${REGEX_LIBRARIES}) diff --git a/cmake/FindREGEX.cmake b/contrib/10.regexp/cmake/FindREGEX.cmake similarity index 100% rename from cmake/FindREGEX.cmake rename to contrib/10.regexp/cmake/FindREGEX.cmake diff --git a/contrib/10.regexp/t/test.scm b/contrib/10.regexp/t/test.scm new file mode 100644 index 00000000..b2a76f49 --- /dev/null +++ b/contrib/10.regexp/t/test.scm @@ -0,0 +1,11 @@ +(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 '(("abcd") ("b")) (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 "newline tab spase " (regexp-replace (regexp "\\s") " " "newline +tab space ")) diff --git a/contrib/20.for/CMakeLists.txt b/contrib/20.for/CMakeLists.txt index ebe66a42..9b0f64f0 100644 --- a/contrib/20.for/CMakeLists.txt +++ b/contrib/20.for/CMakeLists.txt @@ -1,2 +1,2 @@ -file(GLOB FOR_FILES ${PROJECT_SOURCE_DIR}/contrib/20.for/piclib/*.scm) +file(GLOB FOR_FILES ${PICRIN_CONTRIB_DIR}/20.for/piclib/*.scm) list(APPEND PICLIB_CONTRIB_LIBS ${FOR_FILES}) diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index 11050d90..50c586de 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -1,4 +1,5 @@ -file(GLOB CONTRIBS ${PROJECT_SOURCE_DIR}/contrib/*/CMakeLists.txt) +set(PICRIN_CONTRIB_DIR ${PROJECT_SOURCE_DIR}/contrib) +file(GLOB CONTRIBS ${PICRIN_CONTRIB_DIR}/*/CMakeLists.txt) list(SORT CONTRIBS) foreach(contrib ${CONTRIBS}) include(${contrib}) From 0462299bc112c7d7a8907949eb0871175047001f Mon Sep 17 00:00:00 2001 From: "Sunrim KIM (keen)" <3han5chou7@gmail.com> Date: Sun, 20 Jul 2014 18:03:37 +0900 Subject: [PATCH 2/9] remove miscommited test --- contrib/10.regexp/t/test.scm | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 contrib/10.regexp/t/test.scm diff --git a/contrib/10.regexp/t/test.scm b/contrib/10.regexp/t/test.scm deleted file mode 100644 index b2a76f49..00000000 --- a/contrib/10.regexp/t/test.scm +++ /dev/null @@ -1,11 +0,0 @@ -(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 '(("abcd") ("b")) (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 "newline tab spase " (regexp-replace (regexp "\\s") " " "newline -tab space ")) From c78e60f41a91f920714301f30e499be57b1f7b72 Mon Sep 17 00:00:00 2001 From: "Sunrim KIM (keen)" <3han5chou7@gmail.com> Date: Mon, 21 Jul 2014 22:39:27 +0900 Subject: [PATCH 3/9] Revert "make contribs independant of the directory structure of picrin" This reverts commit cdee9d91349ba53a23244d1f3ea5061c8c074975. --- {contrib/10.regexp/cmake => cmake}/FindREGEX.cmake | 0 contrib/10.partcont/CMakeLists.txt | 2 +- contrib/10.pretty-print/CMakeLists.txt | 2 +- contrib/10.regexp/CMakeLists.txt | 5 +---- contrib/20.for/CMakeLists.txt | 2 +- contrib/CMakeLists.txt | 3 +-- 6 files changed, 5 insertions(+), 9 deletions(-) rename {contrib/10.regexp/cmake => cmake}/FindREGEX.cmake (100%) diff --git a/contrib/10.regexp/cmake/FindREGEX.cmake b/cmake/FindREGEX.cmake similarity index 100% rename from contrib/10.regexp/cmake/FindREGEX.cmake rename to cmake/FindREGEX.cmake diff --git a/contrib/10.partcont/CMakeLists.txt b/contrib/10.partcont/CMakeLists.txt index bedbbd75..65f16fb2 100644 --- a/contrib/10.partcont/CMakeLists.txt +++ b/contrib/10.partcont/CMakeLists.txt @@ -1,2 +1,2 @@ -file(GLOB PARTCONT_FILES ${PICRIN_CONTRIB_DIR}/10.partcont/piclib/*.scm) +file(GLOB PARTCONT_FILES ${PROJECT_SOURCE_DIR}/contrib/10.partcont/piclib/*.scm) list(APPEND PICLIB_CONTRIB_LIBS ${PARTCONT_FILES}) diff --git a/contrib/10.pretty-print/CMakeLists.txt b/contrib/10.pretty-print/CMakeLists.txt index c5353018..cf0327da 100644 --- a/contrib/10.pretty-print/CMakeLists.txt +++ b/contrib/10.pretty-print/CMakeLists.txt @@ -1 +1 @@ -list(APPEND PICLIB_CONTRIB_LIBS ${PICRIN_CONTRIB_DIR}/10.pretty-print/pretty-print.scm) +list(APPEND PICLIB_CONTRIB_LIBS ${PROJECT_SOURCE_DIR}/contrib/10.pretty-print/pretty-print.scm) diff --git a/contrib/10.regexp/CMakeLists.txt b/contrib/10.regexp/CMakeLists.txt index aa177aaa..6ab06aaa 100644 --- a/contrib/10.regexp/CMakeLists.txt +++ b/contrib/10.regexp/CMakeLists.txt @@ -1,14 +1,11 @@ # regex -set(PICRIN_REGEX_DIR ${PICRIN_CONTRIB_DIR}/10.regexp) -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PICRIN_REGEX_DIR}/cmake/") - find_package(REGEX) if (REGEX_FOUND) add_definitions(${REGEX_DEFINITIONS}) include_directories(${REGEX_INCLUDE_DIR}) - file(GLOB PICRIN_REGEX_SOURCES ${PICRIN_REGEX_DIR}/src/*.c) + file(GLOB PICRIN_REGEX_SOURCES ${PROJECT_SOURCE_DIR}/contrib/10.regexp/src/*.c) list(APPEND PICRIN_CONTRIB_INITS regexp) list(APPEND PICRIN_CONTRIB_LIBRARIES ${REGEX_LIBRARIES}) diff --git a/contrib/20.for/CMakeLists.txt b/contrib/20.for/CMakeLists.txt index 9b0f64f0..ebe66a42 100644 --- a/contrib/20.for/CMakeLists.txt +++ b/contrib/20.for/CMakeLists.txt @@ -1,2 +1,2 @@ -file(GLOB FOR_FILES ${PICRIN_CONTRIB_DIR}/20.for/piclib/*.scm) +file(GLOB FOR_FILES ${PROJECT_SOURCE_DIR}/contrib/20.for/piclib/*.scm) list(APPEND PICLIB_CONTRIB_LIBS ${FOR_FILES}) diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index 50c586de..11050d90 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -1,5 +1,4 @@ -set(PICRIN_CONTRIB_DIR ${PROJECT_SOURCE_DIR}/contrib) -file(GLOB CONTRIBS ${PICRIN_CONTRIB_DIR}/*/CMakeLists.txt) +file(GLOB CONTRIBS ${PROJECT_SOURCE_DIR}/contrib/*/CMakeLists.txt) list(SORT CONTRIBS) foreach(contrib ${CONTRIBS}) include(${contrib}) From 6bc0a6425580b3d91003e8d93ccbde526b53b4a2 Mon Sep 17 00:00:00 2001 From: "Sunrim KIM (keen)" <3han5chou7@gmail.com> Date: Mon, 21 Jul 2014 22:43:25 +0900 Subject: [PATCH 4/9] mv FindREGEXP.cmake to under 10.regexp --- {cmake => contrib/10.regexp/cmake}/FindREGEX.cmake | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {cmake => contrib/10.regexp/cmake}/FindREGEX.cmake (100%) diff --git a/cmake/FindREGEX.cmake b/contrib/10.regexp/cmake/FindREGEX.cmake similarity index 100% rename from cmake/FindREGEX.cmake rename to contrib/10.regexp/cmake/FindREGEX.cmake From 5f30b37fd9399d12edee96890c8451baf9e77f43 Mon Sep 17 00:00:00 2001 From: "Sunrim KIM (keen)" <3han5chou7@gmail.com> Date: Tue, 22 Jul 2014 21:33:03 +0900 Subject: [PATCH 5/9] add custom target `test-contrib` and make `make test` runs that --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b2929567..1d714658 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,11 +40,14 @@ include(tools/CMakeLists.txt) add_custom_target(run bin/picrin DEPENDS repl) # $ make test -add_custom_target(test DEPENDS test-r7rs) +add_custom_target(test DEPENDS test-r7rs test-contribs) # $ make test-r7rs add_custom_target(test-r7rs bin/picrin ${PROJECT_SOURCE_DIR}/t/r7rs-tests.scm DEPENDS repl) +# $ make test-contribs +add_custom_target(test-contribs DEPENDS ${CONTRIB_TESTS}) + # $ make tak add_custom_target(tak bin/picrin ${PROJECT_SOURCE_DIR}/etc/tak.scm DEPENDS repl) From 561cfc9816341ae2e965ecbbd52e3c4a504b40b0 Mon Sep 17 00:00:00 2001 From: "Sunrim KIM (keen)" <3han5chou7@gmail.com> Date: Tue, 22 Jul 2014 21:34:23 +0900 Subject: [PATCH 6/9] add test for regexp --- contrib/10.regexp/CMakeLists.txt | 2 ++ contrib/10.regexp/t/test.scm | 12 ++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 contrib/10.regexp/t/test.scm diff --git a/contrib/10.regexp/CMakeLists.txt b/contrib/10.regexp/CMakeLists.txt index b416888a..c13c76d3 100644 --- a/contrib/10.regexp/CMakeLists.txt +++ b/contrib/10.regexp/CMakeLists.txt @@ -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() diff --git a/contrib/10.regexp/t/test.scm b/contrib/10.regexp/t/test.scm new file mode 100644 index 00000000..1b2a5c21 --- /dev/null +++ b/contrib/10.regexp/t/test.scm @@ -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 ")) From 0842983363868982f6748325339a27485428f8f7 Mon Sep 17 00:00:00 2001 From: "Sunrim KIM (keen)" <3han5chou7@gmail.com> Date: Tue, 22 Jul 2014 21:35:03 +0900 Subject: [PATCH 7/9] add test for `for` --- contrib/20.for/CMakeLists.txt | 2 ++ contrib/20.for/t/test.scm | 13 +++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 contrib/20.for/t/test.scm diff --git a/contrib/20.for/CMakeLists.txt b/contrib/20.for/CMakeLists.txt index ebe66a42..5e109d90 100644 --- a/contrib/20.for/CMakeLists.txt +++ b/contrib/20.for/CMakeLists.txt @@ -1,2 +1,4 @@ file(GLOB FOR_FILES ${PROJECT_SOURCE_DIR}/contrib/20.for/piclib/*.scm) list(APPEND PICLIB_CONTRIB_LIBS ${FOR_FILES}) +add_custom_target(test-for for test in ${PROJECT_SOURCE_DIR}/contrib/20.for/t/*.scm \; do bin/picrin "$$test" \; done DEPENDS repl) +set(CONTRIB_TESTS ${CONTRIB_TESTS} test-for) diff --git a/contrib/20.for/t/test.scm b/contrib/20.for/t/test.scm new file mode 100644 index 00000000..0f58ae4e --- /dev/null +++ b/contrib/20.for/t/test.scm @@ -0,0 +1,13 @@ +(import (scheme base) + (picrin control list) + (picrin test)) + +(test '(1 2 3) + (for + (yield (in '(1 2 3))))) + +(test '((1 a) (1 b) (1 c) (2 a) (2 b) (2 c) (3 a) (3 b) (3 c)) + (for + (let ((n (in '(1 2 3))) + (c (in '(a b c)))) + (yield (list n c))))) From 2b9d877d665297b70570b8b9da2a106dfcf8e059 Mon Sep 17 00:00:00 2001 From: "Sunrim KIM (keen)" <3han5chou7@gmail.com> Date: Tue, 22 Jul 2014 21:49:06 +0900 Subject: [PATCH 8/9] fix the test cases of `regexp-replace` --- contrib/10.regexp/t/test.scm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/10.regexp/t/test.scm b/contrib/10.regexp/t/test.scm index 1b2a5c21..3c90493f 100644 --- a/contrib/10.regexp/t/test.scm +++ b/contrib/10.regexp/t/test.scm @@ -7,6 +7,6 @@ (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 ")) +(test "a b c d" (regexp-replace (regexp ",") "a,b,c,d" " ")) +(test "newline tab space " (regexp-replace (regexp "\\s") "newline +tab space " " ")) From 52a58e523111acefe858f0ba2a7ce03da81c7cd0 Mon Sep 17 00:00:00 2001 From: "Sunrim KIM (keen)" <3han5chou7@gmail.com> Date: Tue, 22 Jul 2014 21:54:02 +0900 Subject: [PATCH 9/9] add test case for `null` of (picrin control for) --- contrib/20.for/t/test.scm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/contrib/20.for/t/test.scm b/contrib/20.for/t/test.scm index 0f58ae4e..64873a4b 100644 --- a/contrib/20.for/t/test.scm +++ b/contrib/20.for/t/test.scm @@ -11,3 +11,11 @@ (let ((n (in '(1 2 3))) (c (in '(a b c)))) (yield (list n c))))) + +(test '((2 a) (2 b) (2 c)) + (for + (let ((n (in '(1 2 3))) + (c (in '(a b c)))) + (if (even? n) + (yield (list n c)) + (null)))))