File: 001_basic_class_setup.t

package info (click to toggle)
libmoose-perl 1.09-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 3,004 kB
  • ctags: 1,472
  • sloc: perl: 25,387; makefile: 2
file content (52 lines) | stat: -rw-r--r-- 1,275 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/perl

use strict;
use warnings;

use Test::More;
use Test::Exception;


{
    package Foo;
    use Moose;
    use Moose::Util::TypeConstraints;
}

can_ok('Foo', 'meta');
isa_ok(Foo->meta, 'Moose::Meta::Class');

ok(Foo->meta->has_method('meta'), '... we got the &meta method');
ok(Foo->isa('Moose::Object'), '... Foo is automagically a Moose::Object');

dies_ok {
   Foo->meta->has_method()
} '... has_method requires an arg';

can_ok('Foo', 'does');

foreach my $function (qw(
                         extends
                         has
                         before after around
                         blessed confess
                         type subtype as where
                         coerce from via
                         find_type_constraint
                         )) {
    ok(!Foo->meta->has_method($function), '... the meta does not treat "' . $function . '" as a method');
}

foreach my $import (qw(
    blessed
    try
    catch
    in_global_destruction
)) {
    ok(!Moose::Object->can($import), "no namespace pollution in Moose::Object ($import)" );

    local $TODO = $import eq 'blessed' ? "no automatic namespace cleaning yet" : undef;
    ok(!Foo->can($import), "no namespace pollution in Moose::Object ($import)" );
}

done_testing;