Dragging in some modules when X86Compiler is used, so scripts can use them.
[trylon.git] / tests / utf8 / main
blob779dcb9ddf54c12f87d32c3c88697ca2c1e33253
1 trylon utf8-test
3 main: args
4         try
5                 test-utf8
6         catch
7                 send: exception message
8         return 0
11 test-utf8
12         test-string = "¶ µ abc ©"
13         for c in test-string characters
14                 send: (c char-string, " = ", c string)
15         test-bad-utf8: "\x80" type: "starts with 0x80"
16         test-bad-utf8: "\xC0" type: "0xC0"
17         test-bad-utf8: "\xFE" type: "0xFE"
18         test-bad-utf8: "\xC2" type: "short two-byte"
19         test-bad-utf8: "\xC2 " type: "bad two-byte"
20         test-bad-utf8: "\xE0\x80" type: "short three-byte"
22         # Back-up test.
23         iterator = test-string characters
24         c = iterator next
25         send: (c char-string, " = ", c string)
26         send: "Backing up..."
27         iterator back-up
28         c = iterator next
29         send: (c char-string, " = ", c string)
32 test-bad-utf8: string type: type
33         try
34                 for c in string characters
35                         # Should fail.
36                 send: ("Bad UTF-8 (", type, ") not detected!")
37         catch
38                 if exception message == 'Invalid UTF-8 string.'
39                         send: ("Bad UTF-8 string (", type, ") detected correctly.")
40                 else
41                         throw exception