diff --git a/src/regex__FFI.js b/src/regex__FFI.js index 1062520..37115b7 100644 --- a/src/regex__FFI.js +++ b/src/regex__FFI.js @@ -44,7 +44,7 @@ doMatch: function(needle_string, haystack) { if (result) { for (var i = 0; i < result.length; i++) { result[i] = {start: haystack.indexOf(result[i]), - length: result[i].length}; + length: result[i] !== undefined? result[i].length : 0}; } } else { result = [] diff --git a/tests/test.ur b/tests/test.ur index 622c735..8cf5178 100644 --- a/tests/test.ur +++ b/tests/test.ur @@ -154,22 +154,44 @@ end fun format_results (res: string): transaction page = returnBlob (textBlob res) (blessMime "text/plain") + (* +fun format_results_client (res : transaction string) : transaction page = + return + + Test + + +
{[r]}
}/> + +*) + (* ****** ****** *) +fun index_tests () = + tests ( + {E = concat (literal "a") (capture [#X] (literal "b")), R = "a(b)", G = {X=0}, F = _}, + {E = alt (capture [#X] (literal "abcdef")) (concat (literal "Z") any), R = "(?:(abcdef))|(?:Z.)", G = {X=0}, F = _}, + {E = concat (capture [#A] (literal "ab")) (concat (literal "c") (capture [#B] (literal "d"))), R = "(ab)c(d)", G = {A=0, B=1}, F = _}, + {E = capture [#C] (concat (capture [#A] (literal "ab")) (concat (literal "c") (capture [#B] (literal "d")))), R = "((ab)c(d))", G = {A=1, B=2, C=0}, F = _}, + {E = capture [#A] (concat (literal "z") (capture [#B] (literal "a"))), R = "(z(a))", G = {A=0, B=1}, F = _}) + fun index (): transaction page = - format_results - (tests ( - {E = concat (literal "a") (capture [#X] (literal "b")), R = "a(b)", G = {X=0}, F = _}, - {E = alt (capture [#X] (literal "abcdef")) (concat (literal "Z") any), R = "(?:(abcdef))|(?:Z.)", G = {X=0}, F = _}, - {E = concat (capture [#A] (literal "ab")) (concat (literal "c") (capture [#B] (literal "d"))), R = "(ab)c(d)", G = {A=0, B=1}, F = _}, - {E = capture [#C] (concat (capture [#A] (literal "ab")) (concat (literal "c") (capture [#B] (literal "d")))), R = "((ab)c(d))", G = {A=1, B=2, C=0}, F = _}, - {E = capture [#A] (concat (literal "z") (capture [#B] (literal "a"))), R = "(z(a))", G = {A=0, B=1}, F = _} - )) + format_results (index_tests ()) +fun index_client (): transaction page = +(* format_results_client (return (index_tests ()))*) + return + + Test + + +
{[r]}
end}/> + + (* ****** ****** *) -fun groups (): transaction page = +fun groups_test () = s1 <- return ( match_eq (concat (literal "a") (capture [#X] (literal "b"))) "ab" {X = Some "b"} 1 ); @@ -201,4 +223,19 @@ fun groups (): transaction page = in match_eq re "b" {A = None} 4 end); - format_results (s1 ^ "\n" ^ s2 ^ "\n" ^ s3 ^ "\n" ^ s4) + return (s1 ^ "\n" ^ s2 ^ "\n" ^ s3 ^ "\n" ^ s4) + +fun groups (): transaction page = + res <- groups_test (); + format_results res + +fun groups_client (): transaction page = +(* format_results_client (groups_test ())*) + return + + Test + + +
{[r]}
}/> + + diff --git a/tests/test.urp b/tests/test.urp index 69ebf67..c62b4dc 100644 --- a/tests/test.urp +++ b/tests/test.urp @@ -3,5 +3,6 @@ debug rewrite url Test/* allow mime text/plain monoInline 10 +#clientOnly Test.format_results_client test \ No newline at end of file