no trailing whitespace
[gitmo/MooseX-Types.git] / t / 16_introspection.t
1 #!/usr/bin/env perl
2 use strict;
3 use warnings;
4
5 use Test::More;
6
7 use FindBin;
8 use lib "$FindBin::Bin/lib";
9
10 do {
11     package IntrospectionTest;
12     use IntrospectTypeExports   __PACKAGE__, qw( TwentyThree NonEmptyStr MyNonEmptyStr );
13     use TestLibrary             qw( TwentyThree );
14     use IntrospectTypeExports   __PACKAGE__, qw( TwentyThree NonEmptyStr MyNonEmptyStr );
15     use TestLibrary             NonEmptyStr => { -as => 'MyNonEmptyStr' };
16     use IntrospectTypeExports   __PACKAGE__, qw( TwentyThree NonEmptyStr MyNonEmptyStr );
17
18     sub NotAType () { 'just a string' }
19
20     BEGIN {
21         eval {
22             IntrospectTypeExports->import(__PACKAGE__, qw( NotAType ));
23         };
24         ::ok(!$@, "introspecting something that's not not a type doesn't blow up");
25     }
26
27     BEGIN {
28         no strict 'refs';
29         delete ${'IntrospectionTest::'}{TwentyThree};
30     }
31 };
32
33 use IntrospectTypeExports IntrospectionTest => qw( TwentyThree NonEmptyStr MyNonEmptyStr );
34
35 my $P = 'IntrospectionTest';
36
37 is_deeply(IntrospectTypeExports->get_memory, [
38
39     [$P, TwentyThree    => undef],
40     [$P, NonEmptyStr    => undef],
41     [$P, MyNonEmptyStr  => undef],
42
43     [$P, TwentyThree    => 'TestLibrary::TwentyThree'],
44     [$P, NonEmptyStr    => undef],
45     [$P, MyNonEmptyStr  => undef],
46
47     [$P, TwentyThree    => 'TestLibrary::TwentyThree'],
48     [$P, NonEmptyStr    => undef],
49     [$P, MyNonEmptyStr  => 'TestLibrary::NonEmptyStr'],
50
51     [$P, NotAType       => undef],
52
53     [$P, TwentyThree    => undef],
54     [$P, NonEmptyStr    => undef],
55     [$P, MyNonEmptyStr  => 'TestLibrary::NonEmptyStr'],
56
57 ], 'all calls to has_available_type_export returned correct results');
58
59 done_testing();