1 ! Copyright (C) 2009 Daniel Ehrenberg
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: regexp.combinators tools.test regexp kernel sequences ;
4 IN: regexp.combinators.tests
6 : strings ( -- regexp )
7 { "foo" "bar" "baz" } <any-of> ;
9 [ t t t ] [ "foo" "bar" "baz" [ strings matches? ] tri@ ] unit-test
10 [ f f f ] [ "food" "ibar" "ba" [ strings matches? ] tri@ ] unit-test
13 { R' .*a' R' b.*' } <and> ;
15 [ t ] [ "bljhasflsda" conj matches? ] unit-test
16 [ f ] [ "bsdfdfs" conj matches? ] unit-test
17 [ f ] [ "fsfa" conj matches? ] unit-test
19 [ f ] [ "bljhasflsda" conj <not> matches? ] unit-test
20 [ t ] [ "bsdfdfs" conj <not> matches? ] unit-test
21 [ t ] [ "fsfa" conj <not> matches? ] unit-test
23 [ f f ] [ "" "hi" [ <nothing> matches? ] bi@ ] unit-test
24 [ t t ] [ "" "hi" [ <nothing> <not> matches? ] bi@ ] unit-test
26 [ { t t t f } ] [ { "" "a" "aaaaa" "aab" } [ "a" <literal> <zero-or-more> matches? ] map ] unit-test
27 [ { f t t f } ] [ { "" "a" "aaaaa" "aab" } [ "a" <literal> <one-or-more> matches? ] map ] unit-test
28 [ { t t f f } ] [ { "" "a" "aaaaa" "aab" } [ "a" <literal> <option> matches? ] map ] unit-test