Commit | Line | Data |
4e002eb0 |
1 | BEGIN { |
2 | chdir 't' if -d 't'; |
3 | @INC = '../lib'; |
1ae0ae17 |
4 | require './test.pl'; |
4e002eb0 |
5 | } |
6 | |
1ae0ae17 |
7 | plan tests => 9; |
4e002eb0 |
8 | |
1ae0ae17 |
9 | my $a = chr(0x100); |
4e002eb0 |
10 | |
1ae0ae17 |
11 | is(ord($a), 0x100, "ord sanity check"); |
12 | is(length($a), 1, "length sanity check"); |
13 | is(bytes::length($a), 2, "bytes::length sanity check"); |
4e002eb0 |
14 | |
15 | { |
16 | use bytes; |
1ae0ae17 |
17 | my $b = chr(0x100); # affected by 'use bytes' |
18 | is(ord($b), 0, "chr truncates under use bytes"); |
19 | is(length($b), 1, "length truncated under use bytes"); |
20 | is(bytes::length($b), 1, "bytes::length truncated under use bytes"); |
4e002eb0 |
21 | } |
22 | |
1ae0ae17 |
23 | my $c = chr(0x100); |
4e002eb0 |
24 | |
25 | { |
26 | use bytes; |
1ae0ae17 |
27 | if (ord('A') == 193) { # EBCDIC? |
28 | is(ord($c), 0x8c, "ord under use bytes looks at the 1st byte"); |
0ef00eb6 |
29 | } else { |
1ae0ae17 |
30 | is(ord($c), 0xc4, "ord under use bytes looks at the 1st byte"); |
0ef00eb6 |
31 | } |
1ae0ae17 |
32 | is(length($c), 2, "length under use bytes looks at bytes"); |
33 | is(bytes::length($c), 2, "bytes::length under use bytes looks at bytes"); |
4e002eb0 |
34 | } |