Commit | Line | Data |
---|---|---|
4e002eb0 JH |
1 | BEGIN { |
2 | chdir 't' if -d 't'; | |
3 | @INC = '../lib'; | |
18729d3e | 4 | require './test.pl'; |
4e002eb0 JH |
5 | } |
6 | ||
18729d3e | 7 | plan tests => 9; |
4e002eb0 | 8 | |
18729d3e | 9 | my $a = chr(0x100); |
4e002eb0 | 10 | |
18729d3e JH |
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 JH |
14 | |
15 | { | |
16 | use bytes; | |
18729d3e JH |
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 JH |
21 | } |
22 | ||
18729d3e | 23 | my $c = chr(0x100); |
4e002eb0 JH |
24 | |
25 | { | |
26 | use bytes; | |
18729d3e JH |
27 | if (ord('A') == 193) { # EBCDIC? |
28 | is(ord($c), 0x8c, "ord under use bytes looks at the 1st byte"); | |
0ef00eb6 | 29 | } else { |
18729d3e | 30 | is(ord($c), 0xc4, "ord under use bytes looks at the 1st byte"); |
0ef00eb6 | 31 | } |
18729d3e JH |
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 | } |