| 1 |
val tests = [ |
| 2 |
"\"hello\\\"", |
| 3 |
"c:\\foo.bah", |
| 4 |
"", |
| 5 |
"hi\\", |
| 6 |
"hi\"", |
| 7 |
"evil\narg", |
| 8 |
"evil\targ", |
| 9 |
"evil arg", |
| 10 |
"evil\rarg", |
| 11 |
"evil\farg", |
| 12 |
"\"bar\\", |
| 13 |
"\\bah", |
| 14 |
"bah \\bar", |
| 15 |
"bah\\bar", |
| 16 |
"bah\\\\", |
| 17 |
"ba h\\\\", |
| 18 |
"holy\"smoke", |
| 19 |
"holy \"smoke" ] |
| 20 |
|
| 21 |
val cmd = CommandLine.name () |
| 22 |
val args = CommandLine.arguments () |
| 23 |
|
| 24 |
fun loop ([], []) = print "OK!\n" |
| 25 |
| loop (x::r, y::s) = |
| 26 |
(if x <> y then print ("FAIL: "^x^":"^y^"\n") else (); loop (r, s)) |
| 27 |
| loop (_, _) = print "Wrong argument count\n" |
| 28 |
|
| 29 |
open Posix.Process |
| 30 |
open MLton.Process |
| 31 |
val () = |
| 32 |
if List.length args = 0 |
| 33 |
then let |
| 34 |
val pid = spawn {path = cmd, args = cmd::tests} |
| 35 |
val status = waitpid (W_CHILD pid, []) |
| 36 |
in |
| 37 |
() |
| 38 |
end |
| 39 |
else loop (tests, args) |