What does an empty PERLIO= mean, anyway?
[p5sagit/p5-mst-13.2.git] / t / io / layers.t
index 8b84cf5..6f161cd 100644 (file)
@@ -8,12 +8,18 @@ BEGIN {
        print "1..0 # Skip: not perlio\n";
        exit 0;
     }
+    if (exists $ENV{PERLIO} && $ENV{PERLIO} !~ /^(stdio|perlio|mmap)$/) {
+       print "1..0 # PERLIO='$ENV{PERLIO}' unknown\n";
+       exit 0;
+    }
 }
 
 plan tests => 43;
 
 use Config;
 
+my $NONSTDIO = exists $ENV{PERLIO} && $ENV{PERLIO} ne 'stdio';
+
 SKIP: {
     skip("This perl does not have Encode", 43)
        unless " $Config{extensions} " =~ / Encode /;
@@ -22,11 +28,11 @@ SKIP: {
        my ($result, $expected, $id) = @_;
        my $n = scalar @$expected;
        is($n, scalar @$expected, "$id - layers = $n");
-       if ($ENV{PERLIO}) {
+       if ($NONSTDIO) {
            # Get rid of "unix" and similar OS-specific low lever layer.
            shift(@$result);
            # Change expectations.
-           $expected->[0] = "perlio" if $expected->[0] eq "stdio";
+           $expected->[0] = $ENV{PERLIO} if $expected->[0] eq "stdio";
        }
        for (my $i = 0; $i < $n; $i++) {
            my $j = $expected->[$i];
@@ -34,7 +40,8 @@ SKIP: {
                ok($j->($result->[$i]), "$id - $i is ok");
            } else {
                is($result->[$i], $j,
-                  sprintf("$id - $i is %s", defined $j ? $j : "undef"));
+                  sprintf("$id - $i is %s",
+                          defined $j ? $j : "undef"));
            }
        }
     }
@@ -97,7 +104,7 @@ SKIP: {
        my @results = PerlIO::get_layers(F, details => 1);
 
        # Get rid of "unix" and undef.
-       splice(@results, 0, 2) if $ENV{PERLIO};
+       splice(@results, 0, 2) if $NONSTDIO;
 
        check([ @results ],
              [ "stdio",    undef,        sub { $_[0] > 0 },