Skip to content

Instantly share code, notes, and snippets.

@fgabolde
Created January 1, 2014 13:24
Show Gist options
  • Save fgabolde/8208004 to your computer and use it in GitHub Desktop.
Save fgabolde/8208004 to your computer and use it in GitHub Desktop.
p5 packages and mop classes, and how they interact
#!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