Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 153 lines (131 sloc) 5.756 kb
288e0461 » moritz
2008-12-22 [t] and [t/spec]
1 use v6;
2
3 use Test;
4
cc341e38 » moritz
2012-04-05 RT #111646, slurpies => infinite .count
5 plan 52;
288e0461 » moritz
2008-12-22 [t] and [t/spec]
6
7 # L<S06/Required parameters/method:>
8 sub a_zero () { };
8dc7d4b8 » lwall
2010-07-15 [t/spec] mark various tests that intentionally declare things that ar…
9 sub a_one ($a) { }; #OK not used
10 sub a_two ($a, $b) { }; #OK not used
11 sub a_three ($a, $b, @c) { }; #OK not used
12 sub a_four ($a, $b, @c, %d) { }; #OK not used
288e0461 » moritz
2008-12-22 [t] and [t/spec]
13
8dc7d4b8 » lwall
2010-07-15 [t/spec] mark various tests that intentionally declare things that ar…
14 sub o_zero ($x?, $y?) { }; #OK not used
15 sub o_one ($x, :$y) { }; #OK not used
16 sub o_two ($x, :$y!, :$z) { }; #OK not used
288e0461 » moritz
2008-12-22 [t] and [t/spec]
17
18 is &a_zero.arity, 0, '0 arity &sub';
19 is &a_one.arity, 1, '1 arity &sub';
20 is &a_two.arity, 2, '2 arity &sub';
21 is &a_three.arity, 3, '3 arity &sub';
22 is &a_four.arity, 4, '4 arity &foo';
23
b1c8167e » coke
2012-03-08 pugs fudge
24 #?pugs 5 skip '.count'
8ea59c54 » moritz
2009-03-09 [t/spec] tests for .count on subs
25 is &a_zero.count, 0, '0 count &sub';
26 is &a_one.count, 1, '1 count &sub';
27 is &a_two.count, 2, '2 count &sub';
28 is &a_three.count, 3, '3 count &sub';
29 is &a_four.count, 4, '4 count &foo';
30
b1c8167e » coke
2012-03-08 pugs fudge
31 #?pugs 3 todo
288e0461 » moritz
2008-12-22 [t] and [t/spec]
32 is &o_zero.arity, 0, 'arity 0 sub with optional params';
33 is &o_one.arity, 1, 'arity 1 sub with optional params';
fc90fd17 » jnthn
2011-06-26 .arity and .count ignore nameds.
34 is &o_two.arity, 1, 'arity with optional and required named params';
288e0461 » moritz
2008-12-22 [t] and [t/spec]
35
b1c8167e » coke
2012-03-08 pugs fudge
36 #?pugs 3 skip '.count'
8ea59c54 » moritz
2009-03-09 [t/spec] tests for .count on subs
37 is &o_zero.count, 2, 'count on sub with optional params';
fc90fd17 » jnthn
2011-06-26 .arity and .count ignore nameds.
38 is &o_one.count, 1, 'count on sub with optional params';
39 is &o_two.count, 1, 'count on sub with optional and required named params';
8ea59c54 » moritz
2009-03-09 [t/spec] tests for .count on subs
40
b1c8167e » coke
2012-03-08 pugs fudge
41 #?pugs skip 'parsefail'
502162b2 » moritz
2009-03-04 [t/spec] exercise bare "oh I feel so Haskell" sigils in signatures
42 {
43 sub b_zero () { };
8ea59c54 » moritz
2009-03-09 [t/spec] tests for .count on subs
44 sub b_one ($) { };
45 sub b_two ($, $) { };
46 sub b_three ($, $, @) { };
47 sub b_four ($, $, @, %) { };
48 is &b_zero.arity, 0, '0 arity &sub (sigils only)';
49 is &b_one.arity, 1, '1 arity &sub (sigils only)';
50 is &b_two.arity, 2, '2 arity &sub (sigils only)';
51 is &b_three.arity, 3, '3 arity &sub (sigils only)';
52 is &b_four.arity, 4, '4 arity &foo (sigils only)';
502162b2 » moritz
2009-03-04 [t/spec] exercise bare "oh I feel so Haskell" sigils in signatures
53
54 }
55
288e0461 » moritz
2008-12-22 [t] and [t/spec]
56 # It's not really specced in what way (*@slurpy_params) should influence
57 # .arity. Also it's unclear what the result of &multisub.arity is.
58 # See the thread "&multisub.arity?" on p6l started by Ingo Blechschmidt for
59 # details:
60 # L<http://thread.gmane.org/gmane.comp.lang.perl.perl6.language/4915>
61
62 {
63 is ({ $^a }.arity), 1,
64 "block with one placeholder var has .arity == 1";
b1c8167e » coke
2012-03-08 pugs fudge
65 #?pugs 4 skip "is multi"
288e0461 » moritz
2008-12-22 [t] and [t/spec]
66 is (-> $a { $a }.arity), 1,
67 "pointy block with one placeholder var has .arity == 1";
d26e3737 » pmichaud
2008-12-26 [t/spec]: Unfudge arity tests on blocks and pointy subs.
68 is { $^a,$^b }.arity, 2,
288e0461 » moritz
2008-12-22 [t] and [t/spec]
69 "block with two placeholder vars has .arity == 2";
d26e3737 » pmichaud
2008-12-26 [t/spec]: Unfudge arity tests on blocks and pointy subs.
70 is (-> $a, $b { $a,$b }).arity, 2,
288e0461 » moritz
2008-12-22 [t] and [t/spec]
71 "pointy block with two placeholder vars has .arity == 2";
d26e3737 » pmichaud
2008-12-26 [t/spec]: Unfudge arity tests on blocks and pointy subs.
72 is { $^a,$^b,$^c }.arity, 3,
288e0461 » moritz
2008-12-22 [t] and [t/spec]
73 "block with three placeholder vars has .arity == 3";
d26e3737 » pmichaud
2008-12-26 [t/spec]: Unfudge arity tests on blocks and pointy subs.
74 is (-> $a, $b, $c { $a,$b,$c }).arity, 3,
288e0461 » moritz
2008-12-22 [t] and [t/spec]
75 "pointy block with three placeholder vars has .arity == 3";
b1c8167e » coke
2012-03-08 pugs fudge
76
77 #?pugs 6 skip ".count"
8ea59c54 » moritz
2009-03-09 [t/spec] tests for .count on subs
78 is ({ $^a }.count), 1,
79 "block with one placeholder var has .count == 1";
80 is (-> $a { $a }.count), 1,
81 "pointy block with one placeholder var has .count == 1";
82 is { $^a,$^b }.count, 2,
83 "block with two placeholder vars has .count == 2";
84 is (-> $a, $b { $a,$b }).count, 2,
85 "pointy block with two placeholder vars has .count == 2";
86 is { $^a,$^b,$^c }.count, 3,
87 "block with three placeholder vars has .count == 3";
88 is (-> $a, $b, $c { $a,$b,$c }).count, 3,
89 "pointy block with three placeholder vars has .count == 3";
288e0461 » moritz
2008-12-22 [t] and [t/spec]
90 }
91
b1c8167e » coke
2012-03-08 pugs fudge
92 #?pugs skip "is multi"
288e0461 » moritz
2008-12-22 [t] and [t/spec]
93 {
8dc7d4b8 » lwall
2010-07-15 [t/spec] mark various tests that intentionally declare things that ar…
94 is { my $k; $^a }.arity, 1, #OK not used
288e0461 » moritz
2008-12-22 [t] and [t/spec]
95 "additional my() vars don't influence .arity calculation (1-1)";
8dc7d4b8 » lwall
2010-07-15 [t/spec] mark various tests that intentionally declare things that ar…
96 is { my $k; $^a,$^b }.arity, 2, #OK not used
288e0461 » moritz
2008-12-22 [t] and [t/spec]
97 "additional my() vars don't influence .arity calculation (1-2)";
8dc7d4b8 » lwall
2010-07-15 [t/spec] mark various tests that intentionally declare things that ar…
98 is { my $k; $^a,$^b,$^c }.arity, 3, #OK not used
288e0461 » moritz
2008-12-22 [t] and [t/spec]
99 "additional my() vars don't influence .arity calculation (1-3)";
8ea59c54 » moritz
2009-03-09 [t/spec] tests for .count on subs
100
8dc7d4b8 » lwall
2010-07-15 [t/spec] mark various tests that intentionally declare things that ar…
101 is { my $k; $^a }.count, 1, #OK not used
8ea59c54 » moritz
2009-03-09 [t/spec] tests for .count on subs
102 "additional my() vars don't influence .count calculation (1-1)";
8dc7d4b8 » lwall
2010-07-15 [t/spec] mark various tests that intentionally declare things that ar…
103 is { my $k; $^a,$^b }.count, 2, #OK not used
8ea59c54 » moritz
2009-03-09 [t/spec] tests for .count on subs
104 "additional my() vars don't influence .count calculation (1-2)";
8dc7d4b8 » lwall
2010-07-15 [t/spec] mark various tests that intentionally declare things that ar…
105 is { my $k; $^a,$^b,$^c }.count, 3, #OK not used
8ea59c54 » moritz
2009-03-09 [t/spec] tests for .count on subs
106 "additional my() vars don't influence .count calculation (1-3)";
288e0461 » moritz
2008-12-22 [t] and [t/spec]
107 }
108
b1c8167e » coke
2012-03-08 pugs fudge
109 #?pugs skip 'is multi'
288e0461 » moritz
2008-12-22 [t] and [t/spec]
110 {
8dc7d4b8 » lwall
2010-07-15 [t/spec] mark various tests that intentionally declare things that ar…
111 is { $^a; my $k }.arity, 1, #OK not used
288e0461 » moritz
2008-12-22 [t] and [t/spec]
112 "additional my() vars don't influence .arity calculation (2-1)";
8dc7d4b8 » lwall
2010-07-15 [t/spec] mark various tests that intentionally declare things that ar…
113 is { $^a,$^b; my $k }.arity, 2, #OK not used
288e0461 » moritz
2008-12-22 [t] and [t/spec]
114 "additional my() vars don't influence .arity calculation (2-2)";
8dc7d4b8 » lwall
2010-07-15 [t/spec] mark various tests that intentionally declare things that ar…
115 is { $^a,$^b,$^c; my $k }.arity, 3, #OK not used
288e0461 » moritz
2008-12-22 [t] and [t/spec]
116 "additional my() vars don't influence .arity calculation (2-3)";
8ea59c54 » moritz
2009-03-09 [t/spec] tests for .count on subs
117
8dc7d4b8 » lwall
2010-07-15 [t/spec] mark various tests that intentionally declare things that ar…
118 is { $^a; my $k }.count, 1, #OK not used
8ea59c54 » moritz
2009-03-09 [t/spec] tests for .count on subs
119 "additional my() vars don't influence .count calculation (2-1)";
8dc7d4b8 » lwall
2010-07-15 [t/spec] mark various tests that intentionally declare things that ar…
120 is { $^a,$^b; my $k }.count, 2, #OK not used
8ea59c54 » moritz
2009-03-09 [t/spec] tests for .count on subs
121 "additional my() vars don't influence .count calculation (2-2)";
8dc7d4b8 » lwall
2010-07-15 [t/spec] mark various tests that intentionally declare things that ar…
122 is { $^a,$^b,$^c; my $k }.count, 3, #OK not used
8ea59c54 » moritz
2009-03-09 [t/spec] tests for .count on subs
123 "additional my() vars don't influence .count calculation (2-3)";
288e0461 » moritz
2008-12-22 [t] and [t/spec]
124 }
9543526f » moritz
2009-03-09 [t/spec] tests for RT #63744
125
126 # used to be a bug in Rakudo, RT #63744
b1c8167e » coke
2012-03-08 pugs fudge
127 #?pugs skip 'parsefail'
9543526f » moritz
2009-03-09 [t/spec] tests for RT #63744
128 {
129 sub indirect-count(Code $c) { +$c.signature.params; }
8dc7d4b8 » lwall
2010-07-15 [t/spec] mark various tests that intentionally declare things that ar…
130 my $tester = -> $a, $b, $c? { ... }; #OK not used
9543526f » moritz
2009-03-09 [t/spec] tests for RT #63744
131 is +$tester.signature.params, 3, '+$obj.signature.params work';
132 is +$tester.signature.params, indirect-count($tester),
133 '... also when passed to a sub first';
134 }
a3d3a00f » kyle
2009-06-23 [t/spec] Add a test to show bug #66868
135
b1c8167e » coke
2012-03-08 pugs fudge
136 #?pugs todo
a238bb3b » moritz
2011-10-10 remove bogus test
137 dies_ok { eval("a_zero( 'hello', 'world' )") }, 'no matching sub signature';
7f29bc53 » kyle
2009-08-08 [t/spec] Add vim: lines everywhere.
138
b1c8167e » coke
2012-03-08 pugs fudge
139 #?pugs skip 'parsefail'
afae36a5 » moritz
2011-09-26 .count and .arity on multis (RT #76646
140 {
141 my proto sub a($, $?) { * }
142 my multi sub a($) { 1 }
143 my multi sub a($, $) { 2 }
144 is &a.count, 2, '&multi.count';
145 is &a.arity, 1, '&multi.arity';
146 }
147
cc341e38 » moritz
2012-04-05 RT #111646, slurpies => infinite .count
148 # RT #111646
395bd85b » coke
2012-04-11 pugs fudge (new tests)
149 #?pugs 2 skip '.count'
cc341e38 » moritz
2012-04-05 RT #111646, slurpies => infinite .count
150 is (-> *@a { }).count, Inf, 'slurpy positional causes infinite count';
151 is (-> *%a { }).count, 0, 'slurpy named causes no count change';
152
7f29bc53 » kyle
2009-08-08 [t/spec] Add vim: lines everywhere.
153 # vim: ft=perl6
Something went wrong with that request. Please try again.