diff options
author | Nicholas Clark <nick@ccl4.org> | 2005-12-20 14:10:39 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2005-12-20 14:10:39 +0000 |
commit | 63fa9adcade8ebea86e41864381690cdfea27db9 (patch) | |
tree | b820e482bf210bb02d6f7750aea79173f0cef274 /t | |
parent | 98f4023cc000034f1c073b9f79944462b68e983f (diff) | |
download | perl-63fa9adcade8ebea86e41864381690cdfea27db9.tar.gz |
Verify that the code for initialising typeglobs from other types works.
p4raw-id: //depot/perl@26417
Diffstat (limited to 't')
-rwxr-xr-x | t/op/gv.t | 30 |
1 files changed, 29 insertions, 1 deletions
@@ -12,7 +12,7 @@ BEGIN { use warnings; require './test.pl'; -plan( tests => 68 ); +plan( tests => 97 ); # type coersion on assignment $foo = 'foo'; @@ -262,6 +262,34 @@ EOPROG unlike($output, qr/global destruction/, "unreferenced symbol tables should be cleaned up immediately"); } + +# Possibly not the correct test file for these tests. +# There are certain space optimisations implemented via promotion rules to +# GVs + +ok(!exists $::{oonk}, "no symbols of any sort to start with"); + +# A string in place of the typeglob is promoted to the function prototype +$::{oonk} = "pie"; +my $proto = eval 'prototype \&oonk'; +die if $@; +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) { + delete $::{oonk}; + $::{oonk} = \$value; + $proto = eval 'prototype \&oonk'; + die if $@; + is ($proto, '', "Prototype for a constant subroutine is empty"); + + my $got = eval 'oonk'; + die if $@; + is (ref $got, ref $value, "Correct type of value"); + is ($got, $value, "Value is correctly set"); +} __END__ Perl Rules |