diff options
author | 2019-02-13 21:15:00 +0000 | |
---|---|---|
committer | 2019-02-13 21:15:00 +0000 | |
commit | 9f11ffb7133c203312a01e4b986886bc88c7d74b (patch) | |
tree | 6618511204c614b20256e4ef9dea39a7b311d638 /gnu/usr.bin/perl/ext/PerlIO-encoding/t | |
parent | Import perl-5.28.1 (diff) | |
download | wireguard-openbsd-9f11ffb7133c203312a01e4b986886bc88c7d74b.tar.xz wireguard-openbsd-9f11ffb7133c203312a01e4b986886bc88c7d74b.zip |
Fix merge issues, remove excess files - match perl-5.28.1 dist
looking good sthen@, Great! bluhm@
Diffstat (limited to 'gnu/usr.bin/perl/ext/PerlIO-encoding/t')
-rwxr-xr-x | gnu/usr.bin/perl/ext/PerlIO-encoding/t/encoding.t | 22 | ||||
-rwxr-xr-x | gnu/usr.bin/perl/ext/PerlIO-encoding/t/fallback.t | 27 |
2 files changed, 33 insertions, 16 deletions
diff --git a/gnu/usr.bin/perl/ext/PerlIO-encoding/t/encoding.t b/gnu/usr.bin/perl/ext/PerlIO-encoding/t/encoding.t index cba14a82439..41cefcb1377 100755 --- a/gnu/usr.bin/perl/ext/PerlIO-encoding/t/encoding.t +++ b/gnu/usr.bin/perl/ext/PerlIO-encoding/t/encoding.t @@ -16,7 +16,7 @@ BEGIN { require "../../t/charset_tools.pl"; } -use Test::More tests => 24; +use Test::More tests => 27; my $grk = "grk$$"; my $utf = "utf$$"; @@ -25,7 +25,7 @@ my $fail2 = "fb$$"; my $russki = "koi8r$$"; my $threebyte = "3byte$$"; -if (open(GRK, ">$grk")) { +if (open(GRK, '>', $grk)) { binmode(GRK, ":bytes"); # alpha beta gamma in ISO 8859-7 print GRK "\xe1\xe2\xe3"; @@ -40,7 +40,7 @@ if (open(GRK, ">$grk")) { close($i); } -if (open(UTF, "<$utf")) { +if (open(UTF, '<', $utf)) { binmode(UTF, ":bytes"); # alpha beta gamma in UTF-8 Unicode (0x3b1 0x3b2 0x3b3) @@ -57,7 +57,7 @@ if (open(UTF, "<$utf")) { close($i); } -if (open(GRK, "<$grk")) { +if (open(GRK, '<', $grk)) { binmode(GRK, ":bytes"); is(scalar <GRK>, "\xe1\xe2\xe3"); close GRK; @@ -68,10 +68,10 @@ $SIG{__WARN__} = sub {$warn .= $_[0]}; is (open(FAIL, ">:encoding(NoneSuch)", $fail1), undef, 'Open should fail'); like($warn, qr/^Cannot find encoding "NoneSuch" at/); -is(open(RUSSKI, ">$russki"), 1); +is(open(RUSSKI, '>', $russki), 1); print RUSSKI "\x3c\x3f\x78"; close RUSSKI or die "Could not close: $!"; -open(RUSSKI, "$russki"); +open(RUSSKI, '<', $russki); binmode(RUSSKI, ":raw"); my $buf1; read(RUSSKI, $buf1, 1); @@ -231,6 +231,16 @@ is $x, "To hymn him who heard her herd herd\n", } # SKIP +# decoding shouldn't mutate the original bytes [perl #132833] +{ + my $b = "a\0b\0\n\0"; + open my $fh, "<:encoding(UTF16-LE)", \$b or die; + is scalar(<$fh>), "ab\n"; + is $b, "a\0b\0\n\0"; + close $fh or die; + is $b, "a\0b\0\n\0"; +} + END { 1 while unlink($grk, $utf, $fail1, $fail2, $russki, $threebyte); } diff --git a/gnu/usr.bin/perl/ext/PerlIO-encoding/t/fallback.t b/gnu/usr.bin/perl/ext/PerlIO-encoding/t/fallback.t index 17c241c17a0..3abdfd3f37c 100755 --- a/gnu/usr.bin/perl/ext/PerlIO-encoding/t/fallback.t +++ b/gnu/usr.bin/perl/ext/PerlIO-encoding/t/fallback.t @@ -16,7 +16,7 @@ BEGIN { import Encode qw(:fallback_all); } -use Test::More tests => 9; +use Test::More tests => 10; # $PerlIO::encoding = 0; # WARN_ON_ERR|PERLQQ; @@ -33,7 +33,7 @@ my $file = "fallback$$.txt"; like($message, qr/does not map to iso-8859-1/o, "FB_WARN message"); } -open($fh,$file) || die "File cannot be re-opened"; +open($fh,'<',$file) || die "File cannot be re-opened"; my $line = <$fh>; is($line,"\\x{20ac}0.02\n","perlqq escapes"); close($fh); @@ -45,14 +45,14 @@ my $str = "\x{20AC}"; print $fh $str,"0.02\n"; close($fh); -open($fh,$file) || die "File cannot be re-opened"; +open($fh,'<',$file) || die "File cannot be re-opened"; my $line = <$fh>; is($line,"€0.02\n","HTML escapes"); close($fh); { no utf8; - open($fh,">$file") || die "File cannot be re-opened"; + open($fh,'>',$file) || die "File cannot be re-opened"; binmode($fh); print $fh "\xA30.02\n"; close($fh); @@ -64,13 +64,20 @@ printf "# %x\n",ord($line); is($line,"\\xA30.02\n","Escaped non-mapped char"); close($fh); -$PerlIO::encoding::fallback = Encode::WARN_ON_ERROR; +{ + my $message = ''; + local $SIG{__WARN__} = sub { $message = $_[0] }; -ok(open($fh,"<encoding(US-ASCII)",$file),"Opened as ASCII"); -my $line = <$fh>; -printf "# %x\n",ord($line); -is($line,"\x{FFFD}0.02\n","Unicode replacement char"); -close($fh); + $PerlIO::encoding::fallback = Encode::WARN_ON_ERR; + + ok(open($fh,"<encoding(US-ASCII)",$file),"Opened as ASCII"); + my $line = <$fh>; + printf "# %x\n",ord($line); + is($line,"\x{FFFD}0.02\n","Unicode replacement char"); + close($fh); + + like($message, qr/does not map to Unicode/o, "FB_WARN message"); +} END { 1 while unlink($file); |