Commit | Line | Data |
42e595b0 |
1 | #!perl |
2 | use warnings FATAL => 'all'; |
3 | use strict; |
4 | |
5 | use Test::More tests => 29; |
6 | |
7 | use Function::Parameters { |
8 | fun => 'function_strict', |
9 | method => { defaults => 'method_strict', runtime => 1 }, |
10 | }; |
11 | |
12 | { |
13 | package Foo; |
14 | |
15 | ::ok !defined &f1; |
16 | method f1() {} |
17 | ::ok defined &f1; |
18 | |
19 | ::ok !defined &f2; |
20 | ::ok !defined &Bar::f2; |
21 | method Bar::f2() {} |
22 | ::ok !defined &f2; |
23 | ::ok defined &Bar::f2; |
24 | |
25 | ::ok !defined &f3; |
26 | if (@ARGV < 0) { method f3() {} } |
27 | ::ok !defined &f3; |
28 | } |
29 | |
30 | fun g1() { (caller 0)[3] } |
31 | method g2() { (caller 0)[3] } |
32 | fun Bar::g1() { (caller 0)[3] } |
33 | method Bar::g2() { (caller 0)[3] } |
34 | |
35 | is g1, 'main::g1'; |
36 | is 'main'->g2, 'main::g2'; |
37 | is Bar::g1, 'Bar::g1'; |
38 | is 'Bar'->g2, 'Bar::g2'; |
39 | |
40 | use Function::Parameters { fun_r => { defaults => 'function_strict', runtime => 1 } }; |
41 | |
42 | { |
43 | package Foo_r; |
44 | |
45 | ::ok !defined &f1; |
46 | fun_r f1() {} |
47 | ::ok defined &f1; |
48 | |
49 | ::ok !defined &f2; |
50 | ::ok !defined &Bar_r::f2; |
51 | fun_r Bar_r::f2() {} |
52 | ::ok !defined &f2; |
53 | ::ok defined &Bar_r::f2; |
54 | |
55 | ::ok !defined &f3; |
56 | if (@ARGV < 0) { fun_r f3() {} } |
57 | ::ok !defined &f3; |
58 | } |
59 | |
60 | fun h1() { (caller 0)[3] } |
61 | fun_r h2() { (caller 0)[3] } |
62 | fun Bar::h1() { (caller 0)[3] } |
63 | fun_r Bar::h2() { (caller 0)[3] } |
64 | |
65 | is h1, 'main::h1'; |
66 | is h2(), 'main::h2'; |
67 | is Bar::h1, 'Bar::h1'; |
68 | is Bar::h2(), 'Bar::h2'; |
69 | |
70 | fun_r p1($x, $y) :($$) {} |
71 | is prototype(\&p1), '$$'; |
72 | is prototype('p1'), '$$'; |
73 | is prototype('main::p1'), '$$'; |
74 | |
75 | fun_r Bar::p2($x, $y = 0) :($;$) {} |
76 | is prototype(\&Bar::p2), '$;$'; |
77 | is prototype('Bar::p2'), '$;$'; |