USING: arrays regexp tools.test kernel sequences regexp.parser
regexp.private eval strings multiline accessors ;
-IN: regexp-tests
+IN: regexp.tests
{ f } [ "b" "a*" <regexp> matches? ] unit-test
{ t } [ "" "a*" <regexp> matches? ] unit-test
{ t } [ "a" ".+" <regexp> matches? ] unit-test
{ t } [ "ab" ".+" <regexp> matches? ] unit-test
+{ t } [ "\0" "[\\0]" <regexp> matches? ] unit-test
+{ f } [ "0" "[\\0]" <regexp> matches? ] unit-test
+
{ t } [ " " "[\\s]" <regexp> matches? ] unit-test
{ f } [ "a" "[\\s]" <regexp> matches? ] unit-test
{ f } [ " " "[\\S]" <regexp> matches? ] unit-test
{ t } [ "/" "\\/" <regexp> matches? ] unit-test
-{ t } [ "a" R' a'i matches? ] unit-test
+{ t } [ "a" R/ a/i matches? ] unit-test
{ t } [ "" "a|b*|c+|d?" <regexp> matches? ] unit-test
{ t } [ "a" "a|b*|c+|d?" <regexp> matches? ] unit-test
! Comment inside a regular expression
{ t } [ "ac" "a(?#boo)c" <regexp> matches? ] unit-test
-{ } [ "USING: regexp kernel ; R' -{3}[+]{1,6}(?:!!)?\\s' drop" eval( -- ) ] unit-test
+{ } [ "USING: regexp kernel ; R/ -{3}[+]{1,6}(?:!!)?\\s/ drop" eval( -- ) ] unit-test
-{ } [ "USING: regexp kernel ; R' (ftp|http|https)://(\\w+:?\\w*@)?(\\S+)(:[0-9]+)?(/|/([\\w#!:.?+=&%@!\\-/]))?' drop" eval( -- ) ] unit-test
+{ } [ "USING: regexp kernel ; R/ (ftp|http|https):\\/\\/(\\w+:?\\w*@)?(\\S+)(:[0-9]+)?(\\/\\|\\/([\\w#!:.?+=&%@!\\-\\/]))?/ drop" eval( -- ) ] unit-test
-{ } [ "USING: regexp kernel ; R' \\*[^\s*][^*]*\\*' drop" eval( -- ) ] unit-test
+{ } [ "USING: regexp kernel ; R/ \\*[^\s*][^*]*\\*/ drop" eval( -- ) ] unit-test
{ "ab" } [ "ab" "(a|ab)(bc)?" <regexp> first-match >string ] unit-test
{ "abc" } [ "abc" "(a|ab)(bc)?" <regexp> first-match >string ] unit-test
{ "XhXXlXlXoX XwXoXrXlXdX" } [ "hello world" R/ e*/ "X" re-replace ] unit-test
{ "-- title --" } [ "== title ==" R/ =/ "-" re-replace ] unit-test
+{ "abc" } [ "a/ \\bc" "/.*\\" <regexp> "" re-replace ] unit-test
+{ "ac" } [ "a/ \\bc" R/ \/.*\\./ "" re-replace ] unit-test
+{ "abc" } [ "a/ \\bc" R/ \/.*\\/ "" re-replace ] unit-test
+
{ "" } [ "ab" "a(?!b)" <regexp> first-match >string ] unit-test
{ "a" } [ "ac" "a(?!b)" <regexp> first-match >string ] unit-test
{ t } [ "fxxbar" ".{3}(?!foo)bar" <regexp> matches? ] unit-test
{ f } [ "foobxr" "foo(?=bar)" <regexp> first-match ] unit-test
! Bug in parsing word
-{ t } [ "a" R' a' matches? ] unit-test
+{ t } [ "a" R/ a/ matches? ] unit-test
! Testing negation
{ f } [ "a" R/ (?~a)/ matches? ] unit-test
{ 3 } [ "caba" "(?<=b)a" <regexp> first-match from>> ] unit-test
+{ "<" } [ "<style>" R/ <(?=STYLE\b)/i first-match >string ] unit-test
+{ "bar" } [ "foobar" R/ (?<=FOO)BAR/i first-match >string ] unit-test
+
{ t } [ "\ra" R/ .^a/ms matches? ] unit-test
{ f } [ "\ra" R/ .^a/mds matches? ] unit-test
{ t } [ "\na" R/ .^a/ms matches? ] unit-test