diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2005-06-06 23:28:35 +0300 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2005-06-07 09:23:58 +0000 |
commit | 8a064bd6d0d7a44f3e80bed959e1dc566b57850d (patch) | |
tree | 11bc86c9764dc689aabb83da0cecd086a9cd3304 /t | |
parent | dbd54a9fbfac3f28d61d88bb1989ab115b43773d (diff) | |
download | perl-8a064bd6d0d7a44f3e80bed959e1dc566b57850d.tar.gz |
Re: [perl #36130] chr(-1) should probably return undef
Message-ID: <42A487C3.8010306@gmail.com>
p4raw-id: //depot/perl@24720
Diffstat (limited to 't')
-rw-r--r-- | t/op/chr.t | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/t/op/chr.t b/t/op/chr.t index 94450ec1cc..e63c3b56ad 100644 --- a/t/op/chr.t +++ b/t/op/chr.t @@ -6,7 +6,7 @@ BEGIN { require "test.pl"; } -plan tests => 26; +plan tests => 34; # Note that t/op/ord.t already tests for chr() <-> ord() rountripping. @@ -19,11 +19,24 @@ is(chr(127), "\x7F"); is(chr(128), "\x80"); is(chr(255), "\xFF"); -# is(chr(-1), undef); # Shouldn't it be? +is(chr(-0.1), "\x{FFFD}"); # The U+FFFD Unicode replacement character. +is(chr(-1 ), "\x{FFFD}"); +is(chr(-2 ), "\x{FFFD}"); +is(chr(-3.0), "\x{FFFD}"); +{ + use bytes; # Backward compatibility. + is(chr(-0.1), "\x00"); + is(chr(-1 ), "\xFF"); + is(chr(-2 ), "\xFE"); + is(chr(-3.0), "\xFD"); +} # Check UTF-8. -sub hexes { join(" ",map{sprintf"%02x",$_}unpack("C*",chr($_[0]))) } +sub hexes { + no warnings 'utf8'; # avoid surrogate and beyond Unicode warnings + join(" ",map{sprintf"%02x",$_}unpack("C*",chr($_[0]))); +} # The following code points are some interesting steps in UTF-8. is(hexes( 0x100), "c4 80"); |