summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorPiers Cawley <pdcawley@bofh.org.uk>2001-07-06 11:49:01 +0100
committerJarkko Hietaniemi <jhi@iki.fi>2001-07-06 12:18:39 +0000
commitb5aabd38ab0c4a67e0de229508088722c9bbb6c3 (patch)
treeb8963a25307b4ca61aaf66060d9e5f976bf1d9fb /t
parent8b204b88116b37bd108783f065a9cf77156d5409 (diff)
downloadperl-b5aabd38ab0c4a67e0de229508088722c9bbb6c3.tar.gz
(Retracted by #11178)
Subject: [PATCH t/op/method.t] SUPER:: strangeness Message-ID: <m2ith6xu9e.fsf@despairon.bofh.org.uk> p4raw-id: //depot/perl@11172
Diffstat (limited to 't')
-rwxr-xr-xt/op/method.t34
1 files changed, 32 insertions, 2 deletions
diff --git a/t/op/method.t b/t/op/method.t
index 4e4ac97c19..3fc7a4b314 100755
--- a/t/op/method.t
+++ b/t/op/method.t
@@ -9,7 +9,7 @@ BEGIN {
@INC = '../lib';
}
-print "1..72\n";
+print "1..75\n";
@A::ISA = 'B';
@B::ISA = 'C';
@@ -21,7 +21,9 @@ my $cnt = 0;
sub test {
print "# got `$_[0]', expected `$_[1]'\nnot " unless $_[0] eq $_[1];
# print "not " unless shift eq shift;
- print "ok ", ++$cnt, "\n"
+ print "ok ", ++$cnt;
+ print " @_[2..$#_]" if @_ > 2;
+ print "\n";
}
# First, some basic checks of method-calling syntax:
@@ -232,6 +234,34 @@ eval 'sub Foo::boogie { "yes, sir!" }';
test( $::{"Foo::"} ? "ok" : "none", "ok"); # should exist now
test( Foo->boogie(), "yes, sir!");
+# Some simpleminded tests for the SUPER:: pseudoclass.
+# Note that, right now, SUPER:: seems to start looking in the package
+# it was compiled in, rather than in the class it was called in.
+# Which is wrong. Hence the two TODO tests.
+package Parent;
+
+sub foo { 1 };
+
+package Child;
+
+@Child::ISA = 'Parent';
+
+sub child_foo {
+ my $self = shift;
+ $self->SUPER::foo;
+}
+
+package main;
+
+sub Child::main_foo { $_[0]->SUPER::foo }
+
+*Child::late_foo = sub { $_[0]->SUPER::foo };
+
+
+test( scalar(eval {Child->child_foo}), 1 );
+test( scalar(eval {Child->main_foo}), 1, "# TODO SUPER:: non intuitive");
+test( scalar(eval {Child->late_foo}), 1, "# TODO SUPER:: non intuitive");
+
# TODO: universal.t should test NoSuchPackage->isa()/can()
# This is actually testing parsing of indirect objects and undefined subs