7 use constant PERL510 => ( $] >= 5.010 );
11 plan skip_all => "Only subroutine hints supported in 5.8.x";
19 use lib "$FindBin::Bin/lib";
20 use Hints_pod_examples qw(
21 undef_scalar false_scalar zero_scalar empty_list default_list
22 empty_or_false_list undef_n_error_list foo re_fail bar
23 think_positive my_system
26 undef_scalar false_scalar zero_scalar empty_list default_list
27 empty_or_false_list undef_n_error_list foo re_fail bar
28 think_positive my_system
33 # Test code # Exception expected?
35 'undef_scalar()' => 1,
36 'undef_scalar(1)', => 0,
37 'undef_scalar(0)', => 0,
38 'undef_scalar("")', => 0,
40 'false_scalar(0)', => 1,
41 'false_scalar()', => 1,
42 'false_scalar(undef)', => 1,
43 'false_scalar("")', => 1,
44 'false_scalar(1)', => 0,
45 'false_scalar("1")', => 0,
47 'zero_scalar("0")', => 1,
48 'zero_scalar(0)', => 1,
49 'zero_scalar(1)', => 0,
50 'zero_scalar(undef)', => 0,
51 'zero_scalar("")', => 0,
62 're_fail("FAIL")', => 1,
63 're_fail("_FAIL")', => 1,
64 're_fail("_fail")', => 0,
65 're_fail("fail")', => 0,
67 'think_positive(-1)' => 1,
68 'think_positive(-2)' => 1,
69 'think_positive(0)' => 0,
70 'think_positive(1)' => 0,
71 'think_positive(2)' => 0,
82 'empty_list(())', => 1,
83 'empty_list([])', => 0,
84 'empty_list(0)', => 0,
85 'empty_list("")', => 0,
86 'empty_list(undef)', => 0,
88 'default_list()', => 1,
89 'default_list(0)', => 0,
90 'default_list("")', => 0,
91 'default_list(undef)', => 1,
92 'default_list(1)', => 0,
93 'default_list("str")', => 0,
94 'default_list(1, 2)', => 0,
96 'empty_or_false_list()', => 1,
97 'empty_or_false_list(())', => 1,
98 'empty_or_false_list(0)', => 1,
99 'empty_or_false_list(undef)',=> 1,
100 'empty_or_false_list("")', => 1,
101 'empty_or_false_list("0")', => 1,
102 'empty_or_false_list(1,2)', => 0,
103 'empty_or_false_list("a")', => 0,
105 'undef_n_error_list(undef, 1)' => 1,
106 'undef_n_error_list(undef, "a")' => 1,
107 'undef_n_error_list()' => 0,
108 'undef_n_error_list(0, 1)' => 0,
109 'undef_n_error_list("", 1)' => 0,
110 'undef_n_error_list(1)' => 0,
121 're_fail("FAIL")', => 0,
122 're_fail("_FAIL")', => 0,
123 're_fail("_fail")', => 0,
124 're_fail("fail")', => 0,
126 'think_positive(-1)' => 1,
127 'think_positive(-2)' => 1,
128 'think_positive(0)' => 0,
129 'think_positive(1)' => 0,
130 'think_positive(2)' => 0,
138 # On Perl 5.8, autodie doesn't correctly propagate into string evals.
139 # The following snippet forces the use of autodie inside the eval if
140 # we really really have to. For 5.10+, we don't want to include this
141 # fix, because the tests will act as a canary if we screw up string
148 undef_scalar false_scalar zero_scalar empty_list default_list
149 empty_or_false_list undef_n_error_list foo re_fail bar
150 think_positive my_system bizarro_system
154 # Some of the tests provide different hints for scalar or list context
156 while (my ($test, $exception_expected) = each %scalar_tests) {
162 if ($exception_expected) {
163 isnt("$@", "", "scalar test - $test");
166 is($@, "", "scalar test - $test");
170 while (my ($test, $exception_expected) = each %list_tests) {
176 if ($exception_expected) {
177 isnt("$@", "", "array test - $test");
180 is($@, "", "array test - $test");