summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2005-12-20 15:11:09 +0000
committerNicholas Clark <nick@ccl4.org>2005-12-20 15:11:09 +0000
commit5c1f4d79697c25c445705da5672c3103505b0d08 (patch)
treedad02e6a92cbd1af611aaaa38e926fdf0c803850 /t
parentfa75652c1970cc67d47b9b046e2e323ec6b13df9 (diff)
downloadperl-5c1f4d79697c25c445705da5672c3103505b0d08.tar.gz
Croak if gv_init doesn't know how to create a typeglob from that type
of referant. Test that ARRAY, HASH, PVIO, CODE and FORMAT croak. Globs are actually first class assignable objects, so test that you can create a constant subroutine that returns one. p4raw-id: //depot/perl@26422
Diffstat (limited to 't')
-rwxr-xr-xt/op/gv.t22
1 files changed, 19 insertions, 3 deletions
diff --git a/t/op/gv.t b/t/op/gv.t
index e69c1f4d11..ad2db4aa64 100755
--- a/t/op/gv.t
+++ b/t/op/gv.t
@@ -12,7 +12,7 @@ BEGIN {
use warnings;
require './test.pl';
-plan( tests => 97 );
+plan( tests => 105 );
# type coersion on assignment
$foo = 'foo';
@@ -278,7 +278,7 @@ is ($proto, "pie", "String is promoted to prototype");
# A reference to a value is used to generate a constant subroutine
foreach my $value (3, "Perl rules", \42, qr/whatever/, [1,2,3], {1=>2},
- \*STDIN, \&ok, \undef) {
+ \*STDIN, \&ok, \undef, *STDOUT) {
delete $::{oonk};
$::{oonk} = \$value;
$proto = eval 'prototype \&oonk';
@@ -287,9 +287,25 @@ foreach my $value (3, "Perl rules", \42, qr/whatever/, [1,2,3], {1=>2},
my $got = eval 'oonk';
die if $@;
- is (ref $got, ref $value, "Correct type of value");
+ is (ref $got, ref $value, "Correct type of value (" . ref($value) . ")");
is ($got, $value, "Value is correctly set");
}
+
+format =
+.
+
+foreach my $value ([1,2,3], {1=>2}, *STDOUT{IO}, \&ok, *STDOUT{FORMAT}) {
+ # *STDOUT{IO} returns a reference to a PVIO. As it's blessed, ref returns
+ # IO::Handle, which isn't what we want.
+ my $type = $value;
+ $type =~ s/.*=//;
+ $type =~ s/\(.*//;
+ delete $::{oonk};
+ $::{oonk} = $value;
+ $proto = eval 'prototype \&oonk';
+ like ($@, qr/^Cannot convert a reference to $type to typeglob/,
+ "Cannot upgrade ref-to-$type to typeglob");
+}
__END__
Perl
Rules