factor/basis/regexp/parser/parser-tests.factor

25 lines
839 B
Factor
Raw Normal View History

2009-02-16 21:23:00 -05:00
USING: kernel tools.test regexp.parser fry sequences ;
IN: regexp.parser.tests
2009-02-16 21:23:00 -05:00
: regexp-parses ( string -- )
[ [ ] ] dip '[ _ parse-regexp drop ] unit-test ;
2009-04-17 13:46:04 -04:00
: regexp-fails ( string -- regexp )
2009-02-16 21:23:00 -05:00
'[ _ parse-regexp ] must-fail ;
2009-02-16 21:23:00 -05:00
{
"a|b" "a.b" "a|b|c" "abc|b" "a|bcd" "a|(b)" "(?-i:a)" "||"
"(a)|b" "(a|b)" "((a)|(b))" "(?:a)" "(?i:a)" "|b" "b|"
"[abc]" "[a-c]" "[^a-c]" "[^]]" "[]a]" "[[]" "[]-a]" "[a-]" "[-]"
"foo*" "(foo)*" "(a|b)|c" "(foo){2,3}" "(foo){2,}"
2009-02-16 21:23:00 -05:00
"(foo){2}" "{2,3}" "{," "{,}" "}" "foo}" "[^]-a]" "[^-]a]"
"[a-]" "[^a-]" "[^a-]" "a{,2}" "(?#foobar)"
"\\p{Space}" "\\t" "\\[" "[\\]]" "\\P{Space}"
"\\ueeee" "\\0333" "\\xff" "\\\\" "\\w"
} [ regexp-parses ] each
2009-02-16 21:23:00 -05:00
{
"[^]" "[]" "a{foo}" "a{,}" "a{}" "(?)" "\\p{foo}" "\\P{foo}"
"\\ueeeg" "\\0339" "\\xfg"
} [ regexp-fails ] each