Verified Commit 63433afd authored by Camil Staps's avatar Camil Staps 🚀

Enhance test program

parent d4d4b761
......@@ -8,27 +8,28 @@ import Regex
Start :: *World -> *World
Start w
# (io,w) = stdio w
# io = loop (Error "waiting for regex") io
# (io,e) = loop (Error "waiting for regex") io stderr
# (ok,w) = fclose io w
# (ok,w) = fclose e w
= w
loop :: (MaybeErrorString Regex) *File -> *File
loop r f
loop :: !(MaybeErrorString Regex) !*File !*File -> *(!*File, !*File)
loop r f err
# (ln,f) = freadline f
# f = f <<< ln
| ln % (0,12) == "# End of test"
= f
= (f,err)
| isMember ln.[0] ['#\\']
= loop r f
= loop r f err
| ln.[0] == '/' && ln.[size ln-2] == '/' // modifiers not supported
= loop (compile $ fromString $ ln % (1,size ln-3)) f
= loop (compile $ fromString $ ln % (1,size ln-3)) f err
| ln.[0] == '/'
= loop (Error "skipped modifiers") f
= loop (Error "skipped modifiers") f err
| ln % (0,3) == " "
| isError r = loop r f
= loop r (print_match (fromOk r) (fromString $ ln % (4,size ln-2)) f)
| isError r = loop r f (err <<< fromError r <<< "\n")
= loop r (print_match (fromOk r) (fromString $ ln % (4,size ln-2)) f) err
| otherwise
= loop r f
= loop r f err
print_match :: !Regex ![Char] *File -> *File
print_match r s f
......
......@@ -159,11 +159,11 @@
dthing
ething
/^\/
/^/
#/^\/
#
#
#/^/
#
/^[0-9]+$/
0
......
......@@ -296,13 +296,13 @@ No match
ething
No match
/^\/
0: \x81
/^/
0: \xff
#/^\/
#
# 0: \x81
#
#/^/
#
# 0: \xff
/^[0-9]+$/
0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment