Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
[nqp]: Add tests for subclassing.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed Oct 28, 2009
1 parent 8199cf6 commit 9bfe3c4
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions t/nqp/28-subclass.t
@@ -0,0 +1,34 @@
#! nqp

# class inheritance

plan(6);

class ABC {
method foo() {
say('ok 1');
}

method bar() {
say('ok 3');
}
}

class XYZ is ABC {
method foo() {
say('ok 2');
}
}


my $abc := ABC.new();
my $xyz := XYZ.new();

$abc.foo();
$xyz.foo();
$xyz.bar();
my $xyzhow := $xyz.HOW;
if $xyzhow.isa($xyz, ABC) { say('ok 4') }
if $xyzhow.isa($xyz, XYZ) { say('ok 5') }
say( $xyzhow.isa($abc, XYZ) ?? 'not ok 6' !! 'ok 6' );

0 comments on commit 9bfe3c4

Please sign in to comment.