Created
January 1, 2014 13:24
-
-
Save fgabolde/8208004 to your computer and use it in GitHub Desktop.
p5 packages and mop classes, and how they interact
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!perl | |
use strict; | |
use warnings; | |
use 5.010; | |
use Carp; | |
use Test::More; | |
use Test::Exception; | |
package Foo { | |
use mop; | |
class Foo { | |
use Scalar::Util qw/blessed/; | |
method foo_in_foo { ... } | |
} | |
class Bar { | |
method bar_in_foo { ... } | |
} | |
class ::Foo { | |
method foo { ... } | |
} | |
no mop; | |
} | |
use mop; | |
class Baz { | |
use Scalar::Util qw/reftype/; | |
method baz { ... } | |
} | |
no mop; | |
can_ok('Foo::Foo', 'foo_in_foo'); | |
can_ok('Foo::Bar', 'bar_in_foo'); | |
can_ok('Foo', 'foo'); | |
can_ok('Baz', 'baz'); | |
lives_ok(sub { Foo::blessed([]) }); | |
throws_ok(sub { blessed([]) }, qr/Undefined subroutine &main::blessed/); | |
lives_ok(sub { reftype([]) }); | |
done_testing; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment