Debian Codegraph @

regression/string.fromString.sml

raw
1 fun toString NONE = "NONE"
2 | toString (SOME s) = concat ["SOME [", s, "]"]
3 fun check (s, s') =
4 let val s'' = String.fromString s
5 in if s'' = s'
6 then print (concat ["OK ", toString s'', "\n"])
7 else print (concat ["WRONG ", toString s'', " ", toString s', "\n"])
8 end
9
10 val _ =
11 List.app check
12 [("abc\"def", SOME "abc"),
13 ("\n", NONE),
14 (* from SML Basis manual example *)
15 ("\\q", NONE),
16 ("a\^D", SOME "a"),
17 ("a\\ \\\\q", SOME "a"),
18 ("\\ \\", SOME ""),
19 ("", SOME ""),
20 ("\\ \\\^D", SOME ""),
21 ("\\ a", NONE)]