Commit | Line | Data |
8d063cd8 |
1 | #!./perl |
2 | |
9466bab6 |
3 | BEGIN { |
4 | chdir 't' if -d 't'; |
507b9800 |
5 | @INC = qw(.); |
9466bab6 |
6 | require "test.pl"; |
7 | } |
8 | |
507b9800 |
9 | plan tests => 7; |
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 | |