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