]> gitweb.factorcode.org Git - factor.git/blob - basis/regexp/parser/parser-tests.factor
inverse: Fix docs
[factor.git] / basis / regexp / parser / parser-tests.factor
1 USING: kernel tools.test regexp.parser fry sequences ;
2 IN: regexp.parser.tests
3
4 : regexp-parses ( string -- )
5     [ [ ] ] dip '[ _ parse-regexp drop ] unit-test ;
6
7 : regexp-fails ( string -- )
8     '[ _ parse-regexp ] must-fail ;
9
10 {
11     "a|b" "a.b" "a|b|c" "abc|b" "a|bcd" "a|(b)" "(?-i:a)" "||"
12     "(a)|b" "(a|b)" "((a)|(b))" "(?:a)" "(?i:a)" "|b" "b|"
13     "[abc]" "[a-c]" "[^a-c]" "[^]]" "[]a]" "[[]" "[]-a]" "[a-]" "[-]"
14     "foo*" "(foo)*" "(a|b)|c" "(foo){2,3}" "(foo){2,}"
15     "(foo){2}" "{2,3}" "{," "{,}" "}" "foo}" "[^]-a]" "[^-]a]"
16     "[a-]" "[^a-]" "[^a-]" "a{,2}" "(?#foobar)"
17     "\\p{Space}" "\\t" "\\[" "[\\]]" "\\P{Space}"
18     "\\ueeee" "\\0333" "\\xff" "\\\\" "\\w"
19 } [ regexp-parses ] each
20
21 {
22     "[^]" "[]" "a{foo}" "a{,}" "a{}" "(?)" "\\p{foo}" "\\P{foo}"
23     "\\ueeeg" "\\0339" "\\xfg"
24 } [ regexp-fails ] each