Lots of consting
[p5sagit/p5-mst-13.2.git] / t / op / sysio.t
index 61a5c0a..435be12 100755 (executable)
@@ -1,8 +1,9 @@
 #!./perl
 
-print "1..40\n";
+print "1..42\n";
 
 chdir('op') || chdir('t/op') || die "sysio.t: cannot look for myself: $!";
+@INC = '../../lib';
 
 open(I, 'sysio.t') || die "sysio.t: cannot find myself: $!";
 
@@ -211,18 +212,29 @@ print "ok 39\n";
 
 close(I);
 
-{
-    use Fcntl qw(O_RDONLY O_TEXT);
-    open I, ">$outfile";
-    print I "a\nb\nc";
-    close I;
-    sysopen I, $outfile, O_RDONLY|O_TEXT; 
-    sysread I, $buf, 7;
-    print "not " if $buf ne "a\nb\nc";
-    print "ok 40 - sysopen with O_TEXT\n";
-    close I;
-}
+unlink $outfile;
+
+# Check that utf8 IO doesn't upgrade the scalar
+open(I, ">$outfile") || die "sysio.t: cannot write $outfile: $!";
+# Will skip harmlessly on stdioperl
+eval {binmode STDOUT, ":utf8"};
+die $@ if $@ and $@ !~ /^IO layers \(like ':utf8'\) unavailable/;
+
+# y diaresis is \w when UTF8
+$a = chr 255;
+
+print $a =~ /\w/ ? "not ok 40\n" : "ok 40\n";
 
+syswrite I, $a;
+
+# Should not be upgraded as a side effect of syswrite.
+print $a =~ /\w/ ? "not ok 41\n" : "ok 41\n";
+
+# This should work
+eval {syswrite I, 2;};
+print $@ eq "" ? "ok 42\n" : "not ok 42 # $@";
+
+close(I);
 unlink $outfile;
 
 chdir('..');