Verify that the code for initialising typeglobs from other types works.
[p5sagit/p5-mst-13.2.git] / t / uni / chomp.t
index 35eafdf..5f52558 100644 (file)
@@ -3,7 +3,7 @@
 BEGIN {
     if ($ENV{'PERL_CORE'}){
         chdir 't';
-        unshift @INC, '../lib';
+        @INC = '../lib';
     }
     require Config; import Config;
     if ($Config{'extensions'} !~ /\bEncode\b/) {
@@ -18,16 +18,15 @@ BEGIN {
         print "1..0 # Skip: PerlIO required\n";
         exit 0;
     }
-    eval 'use Encode';
-    if ($@ =~ /dynamic loading not available/) {
-        print "1..0 # Skip: no dynamic loading, no Encode\n";
+    if ($ENV{PERL_CORE_MINITEST}) {
+        print "1..0 # Skip: no dynamic loading on miniperl, no Encode\n";
         exit 0;
     }
 }
 
+use Encode;
 use strict;
-# 2 * (@char ** 3) * (keys %mbchars)
-use Test::More tests => 2 * (4 * 4 * 4) * (3);
+use Test::More;
 
 # %mbchars = (encoding => { bytes => utf8, ... }, ...);
 # * pack('C*') is expected to return bytes even if ${^ENCODING} is true.
@@ -46,6 +45,10 @@ our %mbchars = (
     },
 );
 
+# 4 == @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);
+
 for my $enc (sort keys %mbchars) {
     local ${^ENCODING} = find_encoding($enc);
     my @char = (sort(keys   %{ $mbchars{$enc} }),
@@ -70,5 +73,16 @@ for my $enc (sort keys %mbchars) {
                is ($string, $expect); # "$enc \$/=$rs $start $end"
            }
        }
+       # chomp should not stringify references unless it decides to modify
+       # them
+       $_ = [];
+       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)");
 }