summaryrefslogtreecommitdiff
path: root/t/op/misc.t
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>1999-01-02 14:55:06 +0000
committerJarkko Hietaniemi <jhi@iki.fi>1999-01-02 14:55:06 +0000
commit8feb4e9f33850f8c93443f87f3039b93e7d666e1 (patch)
tree4cfdf158fdc684840f05e5f240addc8f94b5235b /t/op/misc.t
parent3e8c4fa08061bc8434ee4407b82fbff46967581d (diff)
downloadperl-8feb4e9f33850f8c93443f87f3039b93e7d666e1.tar.gz
Object destruction order testing.
p4raw-id: //depot/cfgperl@2554
Diffstat (limited to 't/op/misc.t')
-rwxr-xr-xt/op/misc.t43
1 files changed, 42 insertions, 1 deletions
diff --git a/t/op/misc.t b/t/op/misc.t
index f57531c9bd..9fe98c4589 100755
--- a/t/op/misc.t
+++ b/t/op/misc.t
@@ -40,7 +40,7 @@ for (@prgs){
# various yaccs may or may not capitalize 'syntax'.
$results =~ s/^(syntax|parse) error/syntax error/mig;
$expected =~ s/\n+$//;
- if ( $results ne $expected){
+ if ( $results ne $expected ) {
print STDERR "PROG: $switch\n$prog\n";
print STDERR "EXPECTED:\n$expected\n";
print STDERR "GOT:\n$results\n";
@@ -432,3 +432,44 @@ EXPECT
foo
bar
BEGIN failed--compilation aborted at - line 8.
+########
+package X;
+@ISA='Y';
+sub new {
+ my $class = shift;
+ my $self = { };
+ bless $self, $class;
+ my $init = shift;
+ $self->foo($init);
+ print "new", $init;
+ return $self;
+}
+sub DESTROY {
+ my $self = shift;
+ print "DESTROY", $self->foo;
+}
+package Y;
+sub attribute {
+ my $self = shift;
+ my $var = shift;
+ if (@_ == 0) {
+ return $self->{$var};
+ } elsif (@_ == 1) {
+ $self->{$var} = shift;
+ }
+}
+sub AUTOLOAD {
+ $AUTOLOAD =~ /::([^:]+)$/;
+ my $method = $1;
+ splice @_, 1, 0, $method;
+ goto &attribute;
+}
+package main;
+my $x = X->new(1);
+for (2..3) {
+ my $y = X->new($_);
+ print $y->foo;
+}
+print $x->foo;
+EXPECT
+new1new22DESTROY2new33DESTROY31DESTROY1