769ce0efa688369b414e05e305bbacd823142b12
[p5sagit/Function-Parameters.git] / t / types_custom_3.t
1 #!perl
2 use warnings FATAL => 'all';
3 use strict;
4
5 use Test::More tests => 8;
6
7 {
8         package TX;
9
10         sub check { 1 }
11
12         our $obj;
13         BEGIN { $obj = bless {}, 'TX'; }
14 }
15
16 use Function::Parameters {
17         fun => {
18                 check_argument_count => 1,
19                 reify_type => sub {
20                         my ($type, $package) = @_;
21                         if ($package ne $type) {
22                                 my (undef, $file, $line) = @_;
23                                 diag "";
24                                 diag "! $file : $line";
25                         }
26                         is $package, $type;
27                         $TX::obj
28                 },
29         },
30 };
31
32 fun f1(main $x) {}
33 fun Asdf::f1(main $x) {}
34
35 {
36         package Foo::Bar::Baz;
37
38         fun f1(Foo::Bar::Baz $x) {}
39         fun Ghjk::f1(Foo::Bar::Baz $x) {}
40
41         package AAA;
42         fun f1(AAA $x) {}
43         fun main::f2(AAA $x) {}
44 }
45
46 fun f3(main $x) {}
47 fun Ghjk::f2(main $x) {}