6 use Test::More tests => 2 + 3 * 4 + 5 * 2
12 sub Int::TYPEDSCALAR { ++$calls; (caller(0))[2] }
18 my $desc = 'single uninit';
21 is $calls, 1, "$desc: correct number of calls";
22 is $x, __LINE__-2, "$desc: initialized correctly";
26 my $desc = 'double uninit';
29 is $calls, 2, "$desc: correct number of calls";
30 is $x, __LINE__-2, "$desc: initialized \$x correctly";
31 is $y, __LINE__-3, "$desc: initialized \$y correctly";
35 my $desc = 'double uninit with undef begin';
37 my Int (undef, $x, $y);
38 is $calls, 2, "$desc: correct number of calls";
39 is $x, __LINE__-2, "$desc: initialized \$x correctly";
40 is $y, __LINE__-3, "$desc: initialized \$y correctly";
44 my $desc = 'double uninit with undef middle';
46 my Int ($x, undef, $y);
47 is $calls, 2, "$desc: correct number of calls";
48 is $x, __LINE__-2, "$desc: initialized \$x correctly";
49 is $y, __LINE__-3, "$desc: initialized \$y correctly";
53 my $desc = 'double uninit with undef end';
55 my Int ($x, undef, $y);
56 is $calls, 2, "$desc: correct number of calls";
57 is $x, __LINE__-2, "$desc: initialized \$x correctly";
58 is $y, __LINE__-3, "$desc: initialized \$y correctly";
62 my $desc = 'quadruple uninit with parens';
64 my Int ($x, ($y, $z), $t);
65 is $calls, 4, "$desc: correct number of calls";
66 is $x, __LINE__-2, "$desc: initialized \$x correctly";
67 is $y, __LINE__-3, "$desc: initialized \$y correctly";
68 is $z, __LINE__-4, "$desc: initialized \$z correctly";
69 is $t, __LINE__-5, "$desc: initialized \$t correctly";
73 my $desc = 'quadruple uninit with parens and undef';
75 my Int ($x, undef, ($y, undef, $z), undef, $t);
76 is $calls, 4, "$desc: correct number of calls";
77 is $x, __LINE__-2, "$desc: initialized \$x correctly";
78 is $y, __LINE__-3, "$desc: initialized \$y correctly";
79 is $z, __LINE__-4, "$desc: initialized \$z correctly";
80 is $t, __LINE__-5, "$desc: initialized \$t correctly";
84 my $desc = 'single init';
87 is $calls, 1, "$desc: correct number of calls";
88 is $x, 'x', "$desc: initialized correctly";
92 my $desc = 'double init';
94 my Int ($x, $y) = ('x', 'y');
95 is $calls, 2, "$desc: correct number of calls";
96 is $x, 'x', "$desc: initialized \$x correctly";
97 is $y, 'y', "$desc: initialized \$y correctly";
101 my $desc = 'double partial init';
103 my Int ($x, undef, $y) = ('x');
104 is $calls, 2, "$desc: correct number of calls";
105 is $x, 'x', "$desc: initialized \$x correctly";
106 is $y, undef, "$desc: initialized \$y correctly";
110 my $desc = 'quadruple init with parens';
112 my Int ($x, ($y, $z), $t) = ('x', 'y');
113 is $calls, 4, "$desc: correct number of calls";
114 is $x, 'x', "$desc: initialized \$x correctly";
115 is $y, 'y', "$desc: initialized \$y correctly";
116 is $z, undef, "$desc: initialized \$z correctly";
117 is $t, undef, "$desc: initialized \$t correctly";
121 my $desc = 'quadruple init with parens and undef';
123 my Int ($x, ($y, undef, $z), $t) = ('x', 'y');
124 is $calls, 4, "$desc: correct number of calls";
125 is $x, 'x', "$desc: initialized \$x correctly";
126 is $y, 'y', "$desc: initialized \$y correctly";
127 is $z, undef, "$desc: initialized \$z correctly";
128 is $t, undef, "$desc: initialized \$t correctly";
135 is $calls, 0, "$desc: correct number of calls";
136 is $x, 0, "$desc: initialized correctly";
141 my $desc = 'argument list';
144 my Int ($x, $y) = @_;
145 is $calls, 2, "$desc: correct number of calls";
146 is $x, 'x', "$desc: initialized \$x correctly";
147 is $y, 'y', "$desc: initialized \$y correctly";
152 my $desc = 'argument list with undef begin';
155 my Int (undef, $x, $y) = @_;
156 is $calls, 2, "$desc: correct number of calls";
157 is $x, 'y', "$desc: initialized \$x correctly";
158 is $y, undef, "$desc: initialized \$y correctly";
163 my $desc = 'argument list with undef middle';
166 my Int ($x, undef, $y) = @_;
167 is $calls, 2, "$desc: correct number of calls";
168 is $x, 'x', "$desc: initialized \$x correctly";
169 is $y, undef, "$desc: initialized \$y correctly";
174 my $desc = 'argument list with undef end';
177 my Int ($x, $y, undef) = @_;
178 is $calls, 2, "$desc: correct number of calls";
179 is $x, 'x', "$desc: initialized \$x correctly";
180 is $y, 'y', "$desc: initialized \$y correctly";
185 my $desc = 'argument list with parens';
188 my Int ($x, ($y, $z), $t) = @_;
189 is $calls, 4, "$desc: correct number of calls";
190 is $x, 'x', "$desc: initialized \$x correctly";
191 is $y, 'y', "$desc: initialized \$y correctly";
192 is $z, 'z', "$desc: initialized \$z correctly";
193 is $t, 't', "$desc: initialized \$t correctly";
194 }->('x', 'y', 'z', 't');
198 my $desc = 'argument list with parens';
201 my Int ($x, ($y, undef, $z), $t) = @_;
202 is $calls, 4, "$desc: correct number of calls";
203 is $x, 'x', "$desc: initialized \$x correctly";
204 is $y, 'y', "$desc: initialized \$y correctly";
205 is $z, 'z', "$desc: initialized \$z correctly";
206 is $t, undef, "$desc: initialized \$t correctly";
207 }->('x', 'y', 'foo', 'z');