Commit | Line | Data |
8d063cd8 |
1 | #!./perl |
2 | |
9466bab6 |
3 | BEGIN { |
4 | chdir 't' if -d 't'; |
5 | @INC = '.'; |
6 | require "test.pl"; |
7 | } |
8 | |
ecf52eaf |
9 | print "1..8\n"; |
8d063cd8 |
10 | |
11 | # compile time evaluation |
12 | |
ecf52eaf |
13 | # 'A' 65 ASCII |
14 | # 'A' 193 EBCDIC |
8d063cd8 |
15 | |
9466bab6 |
16 | ok(ord('A') == 65 || ord('A') == 193, "ord('A') is ".ord('A')); |
17 | |
18 | is(ord(chr(500)), 500, "compile time chr 500"); |
bed171df |
19 | |
8d063cd8 |
20 | # run time evaluation |
21 | |
22 | $x = 'ABC'; |
bed171df |
23 | |
9466bab6 |
24 | ok(ord($x) == 65 || ord($x) == 193, "ord('$x') is ".ord($x)); |
463ee0b2 |
25 | |
9466bab6 |
26 | ok(chr 65 eq 'A' || chr 193 eq 'A', "chr can produce 'A'"); |
ecf52eaf |
27 | |
bed171df |
28 | $x = 500; |
9466bab6 |
29 | is(ord(chr($x)), $x, "runtime chr $x"); |
ecf52eaf |
30 | |
9466bab6 |
31 | is(ord("\x{1234}"), 0x1234, 'compile time ord \x{....}'); |
ecf52eaf |
32 | |
33 | $x = "\x{1234}"; |
9466bab6 |
34 | is(ord($x), 0x1234, 'runtime ord \x{....}'); |
35 | |
36 | { |
37 | eval 'my $surrogate = chr(0xD800)'; |
38 | |
39 | like($@, qr/^UTF-16 surrogate 0xd800 /, "surrogates bad"); |
40 | } |
41 | |
ecf52eaf |
42 | |