#!./perl -w
BEGIN {
- if ($ENV{'PERL_CORE'}){
- chdir 't';
- unshift @INC, '../lib';
- }
- require Config; import Config;
- if ($Config{'extensions'} !~ /\bEncode\b/) {
- print "1..0 # Skip: Encode was not built\n";
- exit 0;
- }
- if (ord("A") == 193) {
- print "1..0 # Skip: EBCDIC\n";
- exit 0;
- }
- unless (PerlIO::Layer->find('perlio')){
- print "1..0 # Skip: PerlIO required\n";
- exit 0;
- }
- if ($ENV{PERL_CORE_MINITEST}) {
- print "1..0 # Skip: no dynamic loading on miniperl, no Encode\n";
- exit 0;
- }
+ chdir 't' if -d 't';
+ require './test.pl';
+ skip_all_without_perlio();
}
-use Encode;
use strict;
-use Test::More;
-# %mbchars = (encoding => { bytes => utf8, ... }, ...);
-# * pack('C*') is expected to return bytes even if ${^ENCODING} is true.
-our %mbchars = (
- 'big-5' => {
- pack('C*', 0x40) => pack('U*', 0x40), # COMMERCIAL AT
- pack('C*', 0xA4, 0x40) => "\x{4E00}", # CJK-4E00
- },
- 'euc-jp' => {
- pack('C*', 0xB0, 0xA1) => "\x{4E9C}", # CJK-4E9C
- pack('C*', 0x8F, 0xB0, 0xA1) => "\x{4E02}", # CJK-4E02
- },
- 'shift-jis' => {
- pack('C*', 0xA9) => "\x{FF69}", # halfwidth katakana small U
- pack('C*', 0x82, 0xA9) => "\x{304B}", # hiragana KA
- },
-);
-
-# 4 == @char; paired tests inside 3 nested loops,
+# 6 == @char; paired tests inside 3 nested loops,
# plus extra pair of tests in a loop, plus extra pair of tests.
-plan tests => 2 * (4 ** 3 + 4 + 1) * (keys %mbchars);
+plan tests => 6 ** 3 * 2 + 6 * 2 + 2;
-for my $enc (sort keys %mbchars) {
- local ${^ENCODING} = find_encoding($enc);
- my @char = (sort(keys %{ $mbchars{$enc} }),
- sort(values %{ $mbchars{$enc} }));
+my @char = (pack('U*', 0x40), "\x{4E00}", "\x{4E9C}", "\x{4E02}",
+ "\x{FF69}", "\x{304B}");
- for my $rs (@char) {
+for my $rs (@char) {
local $/ = $rs;
for my $start (@char) {
for my $end (@char) {
my $got = chomp();
is ($got, 0);
is (ref($_), "ARRAY", "chomp ref (no modify)");
- }
-
- $/ = ")"; # the last char of something like "ARRAY(0x80ff6e4)"
- my $got = chomp();
- is ($got, 1);
- ok (!ref($_), "chomp ref (modify)");
}
+
+$/ = ")"; # the last char of something like "ARRAY(0x80ff6e4)"
+my $got = chomp();
+is ($got, 1);
+ok (!ref($_), "chomp ref (modify)");
+