diff options
author | Nicholas Clark <nick@ccl4.org> | 2007-12-27 18:43:40 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2007-12-27 18:43:40 +0000 |
commit | 1f257c956c5d42ce792dd5e0f3badf9851cef49c (patch) | |
tree | 32f37ed326308dd1770cf1f5908bb96430fa7f79 /t | |
parent | 124ee91afb4a0db86a0ab6e7348e1f97ae18fc0d (diff) | |
download | perl-1f257c956c5d42ce792dd5e0f3badf9851cef49c.tar.gz |
You can't coerce a typeglob to a string. (Restore the error message -
an assertion failure is not helpful). Test the 3 basic coercion
error messages.
p4raw-id: //depot/perl@32743
Diffstat (limited to 't')
-rwxr-xr-x | t/op/gv.t | 26 |
1 files changed, 25 insertions, 1 deletions
@@ -12,7 +12,7 @@ BEGIN { use warnings; require './test.pl'; -plan( tests => 161 ); +plan( tests => 167 ); # type coersion on assignment $foo = 'foo'; @@ -494,6 +494,30 @@ foreach my $value ([1,2,3], {1=>2}, *STDOUT{IO}, \&ok, *STDOUT{FORMAT}) { "Assigment works when glob created midway (bug 45607)"); 1' or die $@; } + +# For now these tests are here, but they would probably be better in a file for +# tests for croaks. (And in turn, that probably deserves to be in a different +# directory. Gerard Goossen has a point about the layout being unclear + +sub coerce_integer { + no warnings 'numeric'; + $_[0] |= 0; +} +sub coerce_number { + no warnings 'numeric'; + $_[0] += 0; +} +sub coerce_string { + $_[0] .= ''; +} + +foreach my $type (qw(integer number string)) { + my $prog = "coerce_$type(*STDERR)"; + is (scalar eval "$prog; 1", undef, "$prog failed..."); + like ($@, qr/Can't coerce GLOB to $type in/, + "with the correct error message"); +} + __END__ Perl Rules |