Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /smlnj-lib/trunk/RegExp/Tests/test-fn.sml
ViewVC logotype

Diff of /smlnj-lib/trunk/RegExp/Tests/test-fn.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3017, Mon May 5 16:48:42 2008 UTC revision 3080, Wed Jun 11 18:54:52 2008 UTC
# Line 14  Line 14 
14      fun getc s i = if (i < String.size s) then SOME(String.sub(s, i), i+1) else NONE      fun getc s i = if (i < String.size s) then SOME(String.sub(s, i), i+1) else NONE
15    
16      fun test (name, re, data) = let      fun test (name, re, data) = let
17            val re = RE.compileString re            val _ = print(concat["  ", name, ": "])
18              val re = RE.compileString re handle ex => (print "compile failed\n"; raise ex)
19            in            in
20              print(concat["  ", name, ": "]);              case ((RE.find re (getc data) 0) handle ex => NONE)
             case RE.find re (getc data) 0  
21               of NONE => print "match failed\n"               of NONE => print "match failed\n"
22                | SOME(M.Match({pos, len}, _), _) =>                | SOME(M.Match({pos, len}, _), _) =>
23                    print(concat[                    print(concat[
# Line 26  Line 26 
26                      ])                      ])
27              (* end case *)              (* end case *)
28            end            end
29                handle _ => ()
30    
31      fun doTests () = (      fun doTests () = (
32            print(concat["  testing ", engineName, "\n"]);            print(concat["  testing ", engineName, "\n"]);
# Line 33  Line 34 
34            test ("02", "^[0-9]+", "abc123def\n987xyz");            test ("02", "^[0-9]+", "abc123def\n987xyz");
35            test ("03", "[0-9]+$", "abc123def\n987xyz456");            test ("03", "[0-9]+$", "abc123def\n987xyz456");
36            test ("04", "[0-9]+$", "987xyz456\nabc123");            test ("04", "[0-9]+$", "987xyz456\nabc123");
37              test ("05", "^$", "");
38              test ("06", ".", "a");
39              test ("07", "^foo$", "foo");
40              test ("08", "^...$", "foo");
41              test ("09", "^.*$", "foo");
42              test ("10", "^.*foo@bar\\.com$", "foo@bar.com");
43              test ("11", "(abc)","abc");
44              test ("12", "\\(abc\\)","(abc)");
45    (* this syntax is not yet supported
46              test ("13", "(abc){2,4}$", "abcabc");
47              test ("14", "(abc){2,4}$", "abcabcabc");
48              test ("15", "(abc){2,4}$", "abcabcabcabc");
49    *)
50            print "** tests done\n")            print "** tests done\n")
51    
52    end    end

Legend:
Removed from v.3017  
changed lines
  Added in v.3080

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0