tests are expected to fail if dirfd () does not exist
[p5sagit/p5-mst-13.2.git] / t / op / chop.t
index bacc439..a77ff30 100755 (executable)
@@ -6,7 +6,7 @@ BEGIN {
     require './test.pl';
 }
 
-plan tests => 133;
+plan tests => 137;
 
 $_ = 'abc';
 $c = do foo();
@@ -222,3 +222,13 @@ foreach my $start (@chars) {
     $b = chomp $a;
     is ($b, 2);
 }
+
+{
+    # [perl #36569] chop fails on decoded string with trailing nul
+    my $asc = "perl\0";
+    my $utf = "perl".pack('U',0); # marked as utf8
+    is(chop($asc), "\0", "chopping ascii NUL");
+    is(chop($utf), "\0", "chopping utf8 NUL");
+    is($asc, "perl", "chopped ascii NUL");
+    is($utf, "perl", "chopped utf8 NUL");
+}