diff options
Diffstat (limited to 't/extending')
-rwxr-xr-x | t/extending/class.t | 24 | ||||
-rwxr-xr-x | t/extending/file.t | 22 | ||||
-rwxr-xr-x | t/extending/method.t | 21 |
3 files changed, 67 insertions, 0 deletions
diff --git a/t/extending/class.t b/t/extending/class.t new file mode 100755 index 0000000..194cf4c --- /dev/null +++ b/t/extending/class.t @@ -0,0 +1,24 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; +use lib 't/lib'; + +{ + package Foo; + use Moose; + use Command; + + sub foo { + } + + command bar => sub { + }; +} + +ok(Foo->meta->has_method('bar')); +is_deeply([Foo->meta->get_all_commands], [Foo->meta->get_method('bar')]); +ok(Foo->meta->has_command('bar')); +ok(!Foo->meta->has_command('foo')); + +done_testing; diff --git a/t/extending/file.t b/t/extending/file.t new file mode 100755 index 0000000..c6868cd --- /dev/null +++ b/t/extending/file.t @@ -0,0 +1,22 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; +use Test::Exception; +use lib 't/lib'; + +{ + package Foo; + use Moose; + use FileAttributes; + + has_file 'foo'; + has_dir 'bar' => (required => 1); +} + +my $foo = Foo->new(bar => '.'); +isa_ok($foo->bar, 'Path::Class::Dir'); + +throws_ok { Foo->new(foo => 'test.pl') } qr/required/, "bar is required"; + +done_testing; diff --git a/t/extending/method.t b/t/extending/method.t new file mode 100755 index 0000000..8599720 --- /dev/null +++ b/t/extending/method.t @@ -0,0 +1,21 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; +use Test::Output; +use lib 't/lib'; + +{ + package Foo; + use Moose; + use AtomicMethod; + + atomic_method foo => sub { + warn "in foo\n"; + }; +} + +my $foo = Foo->new; +stderr_is(sub { $foo->foo }, "locking...\nin foo\nunlocking...\n"); + +done_testing; |