This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Explicitly mention that even negative shiftees become UVs first.
[perl5.git] / lib / bytes.t
index 6b66a55..8fc535f 100644 (file)
@@ -1,10 +1,11 @@
+
 BEGIN {
     chdir 't' if -d 't';
     @INC = '../lib';
     require './test.pl';
 }
 
-plan tests => 19;
+plan tests => 24;
 
 my $a = chr(0x100);
 
@@ -27,6 +28,8 @@ is(bytes::chr(0x100), chr(0),  "bytes::chr sanity check");
 }
 
 my $c = chr(0x100);
+my $c2 = chr(0x2c7); # a unicode character that doesn't fold
+utf8::encode(my $c2_utf8 = $c2);
 
 {
     use bytes;
@@ -42,7 +45,29 @@ my $c = chr(0x100);
     } else {
        is(bytes::ord($c), 0xc4, "bytes::ord under use bytes looks at the 1st byte");
     }
-    is(bytes::substr($c, 0, 1), "\xc4", "bytes::substr under use bytes looks at bytes");
-    is(bytes::index($c, "\x80"), 1, "bytes::index under use bytes looks at bytes");
-    is(bytes::rindex($c, "\xc4"), 0, "bytes::rindex under use bytes looks at bytes");
+    # In z/OS \x41,\x8c are the codepoints corresponding to \x80,\xc4 respectively under ASCII platform
+    if (ord('A') == 193) { # EBCDIC?
+        is(bytes::substr($c, 0, 1), "\x8c", "bytes::substr under use bytes looks at bytes");
+        is(bytes::index($c, "\x41"), 1, "bytes::index under use bytes looks at bytes");
+        is(bytes::rindex($c, "\x8c"), 0, "bytes::rindex under use bytes looks at bytes");
+
+    }
+    else{
+        is(bytes::substr($c, 0, 1), "\xc4", "bytes::substr under use bytes looks at bytes");
+        is(bytes::index($c, "\x80"), 1, "bytes::index under use bytes looks at bytes");
+        is(bytes::rindex($c, "\xc4"), 0, "bytes::rindex under use bytes looks at bytes");
+    }
+    
+    # [perl #117355] [lu]cfirst don't respect 'use bytes'
+    # and if there's other tests for lc/uc under bytes I didn't find them
+    is(lc($c2), $c2_utf8, "lc under use bytes returns bytes");
+    is(uc($c2), $c2_utf8, "uc under use bytes returns bytes");
+    is(lcfirst($c2), $c2_utf8, "lcfirst under use bytes returns bytes");
+    is(ucfirst($c2), $c2_utf8, "unfirst under use bytes returns bytes");
+}
+
+{
+    fresh_perl_like ('use bytes; bytes::moo()',
+                    qr/Undefined subroutine bytes::moo/, {stderr=>1},
+                   "Check Carp is loaded for AUTOLOADing errors")
 }