Skip distro which requires rpm
[gitmo/Moose.git] / t / basics / basic_class_setup.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Test::More;
7 use Test::Fatal;
8
9
10 {
11     package Foo;
12     use Moose;
13     use Moose::Util::TypeConstraints;
14 }
15
16 can_ok('Foo', 'meta');
17 isa_ok(Foo->meta, 'Moose::Meta::Class');
18
19 ok(Foo->meta->has_method('meta'), '... we got the &meta method');
20 ok(Foo->isa('Moose::Object'), '... Foo is automagically a Moose::Object');
21
22 isnt( exception {
23    Foo->meta->has_method()
24 }, undef, '... has_method requires an arg' );
25
26 can_ok('Foo', 'does');
27
28 foreach my $function (qw(
29                          extends
30                          has
31                          before after around
32                          blessed confess
33                          type subtype as where
34                          coerce from via
35                          find_type_constraint
36                          )) {
37     ok(!Foo->meta->has_method($function), '... the meta does not treat "' . $function . '" as a method');
38 }
39
40 foreach my $import (qw(
41     blessed
42     try
43     catch
44     in_global_destruction
45 )) {
46     ok(!Moose::Object->can($import), "no namespace pollution in Moose::Object ($import)" );
47
48     local $TODO = $import eq 'blessed' ? "no automatic namespace cleaning yet" : undef;
49     ok(!Foo->can($import), "no namespace pollution in Moose::Object ($import)" );
50 }
51
52 done_testing;