-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sml
43 lines (37 loc) · 1.03 KB
/
test.sml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
open MNUtils
val _ = test "test-empty-out" 0 Int.toString (fn () =>
let
val (status, _) = Popen.exec "exit 0;"
in
valOf status
end)
val _ = test "test-short-out" "Hello World!\n" (fn x => x) (fn () =>
let
val (_, out) = Popen.exec "echo 'Hello World!'; exit 0;"
in
valOf out
end)
fun generateLongString acc =
if (String.size acc) > (1024 * 10) then
acc
else
generateLongString (acc ^ "Lorem ipsum ")
val long_string = generateLongString ""
val _ = test "test-long-out" (long_string^"\n") (fn x => x) (fn () =>
let
val (_, out) = Popen.exec ("echo '" ^ long_string ^ "'; exit 0;")
in
valOf out
end)
val _ = test "test-zero-exit-code" 0 Int.toString (fn () =>
let
val (pid, _) = Popen.exec "echo 'Hello World!'; exit 0;"
in
valOf pid
end)
val _ = test "test-non-zero-exit-code" 42 Int.toString (fn () =>
let
val (pid, _) = Popen.exec "echo 'Hello World!'; exit 42;"
in
valOf pid
end)