summaryrefslogtreecommitdiff
path: root/ext/PerlIO-scalar
diff options
context:
space:
mode:
authorTony Cook <tony@develop-help.com>2013-01-25 09:56:14 +1100
committerTony Cook <tony@develop-help.com>2013-01-25 10:27:29 +1100
commitf07ca60cafb35d8601b5bd0da0a7383231de5fec (patch)
tree5e0e8620185c28c49d0c1259301caf4fba04ef31 /ext/PerlIO-scalar
parentb38d579d7e4fdb6e4abade72630ea777d8c509d9 (diff)
downloadperl-f07ca60cafb35d8601b5bd0da0a7383231de5fec.tar.gz
TODO tests for writing to a SVf_UTF8 scalar
Diffstat (limited to 'ext/PerlIO-scalar')
-rw-r--r--ext/PerlIO-scalar/t/scalar.t26
1 files changed, 25 insertions, 1 deletions
diff --git a/ext/PerlIO-scalar/t/scalar.t b/ext/PerlIO-scalar/t/scalar.t
index 3be26c5c8c..833bb20c4c 100644
--- a/ext/PerlIO-scalar/t/scalar.t
+++ b/ext/PerlIO-scalar/t/scalar.t
@@ -16,7 +16,7 @@ use Fcntl qw(SEEK_SET SEEK_CUR SEEK_END); # Not 0, 1, 2 everywhere.
$| = 1;
-use Test::More tests => 101;
+use Test::More tests => 108;
my $fh;
my $var = "aaa\n";
@@ -436,4 +436,28 @@ my $byte_warning = "Strings with code points over 0xFF may not be mapped into in
seek($fh, 1, SEEK_SET);
is(read($fh, $tmp, 1), undef, "read from scalar with >0xff chars");
is_deeply(\@warnings, [ $byte_warning ], "check warning");
+
+ select $fh; # make sure print fails rather tha buffers
+ $| = 1;
+ select STDERR;
+ no warnings "utf8";
+ @warnings = ();
+ $content = "\xA1\xA2\xA3";
+ utf8::upgrade($content);
+ seek($fh, 1, SEEK_SET);
+ ok((print $fh "A"), "print to an upgraded byte string");
+ seek($fh, 1, SEEK_SET);
+ local $TODO = "write to utf8 flagged strings is broken";
+ is($content, "\xA1A\xA3", "check result");
+
+ $content = "\x{101}\x{102}\x{103}";
+ $! = 0;
+ ok(!(print $fh "B"), "write to an non-downgradable SV");
+ is(0+$!, EINVAL, "check errno set");
+
+ is_deeply(\@warnings, [], "should be no warning");
+
+ use warnings "utf8";
+ ok(!(print $fh "B"), "write to an non-downgradable SV (and warn)");
+ is_deeply(\@warnings, [ $byte_warning ], "check warning");
}