Skip to content
Newer
Older
100644 178 lines (144 sloc) 5.27 KB
ce0e942 [t] moved pairs.t to spec/, fudged a bit, added a test
moritz authored Sep 10, 2008
1 use v6;
2
3 use Test;
4
75bf7cb @diakopter fix all the remaining S02/Literals smartlinks I broke by adding headi…
diakopter authored Aug 23, 2011
5 # L<S02/Adverbial Pair forms/"There is now a generalized adverbial form of Pair">
c2f8fec [t] and [t/spec] (two train travels worth of changes):
moritz authored Dec 14, 2008
6
ce0e942 [t] moved pairs.t to spec/, fudged a bit, added a test
moritz authored Sep 10, 2008
7 # See thread "Demagicalizing pair" on p6l started by Luke Palmer,
8 # L<"http://article.gmane.org/gmane.comp.lang.perl.perl6.language/4778/"> and
9 # L<"http://colabti.de/irclogger/irclogger_log/perl6?date=2005-10-09,Sun&sel=528#l830">.
10 # Also see L<"http://www.nntp.perl.org/group/perl.perl6.language/23532">.
11
12 # To summarize:
13 # foo(a => 42); # named
14 # foo(:a(42)); # named
15 #
16 # foo((a => 42)); # pair passed positionally
17 # foo((:a(42))); # pair passed positionally
18 #
19 # my $pair = (a => 42);
20 # foo($pair); # pair passed positionally
c2f8fec [t] and [t/spec] (two train travels worth of changes):
moritz authored Dec 14, 2008
21 # foo(|$pair); # named
9bfcf50 [t/spec] some test enhancements, corrections and fudging for rakudo.
moritz authored Oct 5, 2008
22 #
23 # S02 lists ':a' as being equivlaent to a => 1, so
24 # the type of the value of that pair is Int, not Bool
ce0e942 [t] moved pairs.t to spec/, fudged a bit, added a test
moritz authored Sep 10, 2008
25
1395cad @moritz rewrite pairs.t to conform to current spec
moritz authored Jul 28, 2011
26 plan 79;
ce0e942 [t] moved pairs.t to spec/, fudged a bit, added a test
moritz authored Sep 10, 2008
27
1395cad @moritz rewrite pairs.t to conform to current spec
moritz authored Jul 28, 2011
28 sub f1n (:$a) { $a.WHAT.gist }
29 sub f1p ( $a) { $a.WHAT.gist }
ce0e942 [t] moved pairs.t to spec/, fudged a bit, added a test
moritz authored Sep 10, 2008
30 {
ede6fd4 @coke pugs refudge (for "gist")
coke authored Apr 10, 2012
31 is f1n(a => 42), Int.gist, "'a => 42' is a named";
32 is f1n(:a(42)), Int.gist, "':a(42)' is a named";
1395cad @moritz rewrite pairs.t to conform to current spec
moritz authored Jul 28, 2011
33
ede6fd4 @coke pugs refudge (for "gist")
coke authored Apr 11, 2012
34 is f1n(:a), Bool.gist, "':a' is a named";
35 is f1n(:!a), Bool.gist, "':!a' is also named";
1395cad @moritz rewrite pairs.t to conform to current spec
moritz authored Jul 28, 2011
36
ede6fd4 @coke pugs refudge (for "gist")
coke authored Apr 11, 2012
37 is f1p("a" => 42), Pair.gist, "'\"a\" => 42' is a pair";
38 is f1p(("a") => 42), Pair.gist, "'(\"a\") => 42' is a pair";
39 is f1p((a => 42)), Pair.gist, "'(a => 42)' is a pair";
40 is f1p(("a" => 42)), Pair.gist, "'(\"a\" => 42)' is a pair";
41 is f1p((:a(42)), ), Pair.gist, "'(:a(42))' is a pair";
42 is f1p((:a), ), Pair.gist, "'(:a)' is a pair";
43 is f1p((:!a), ), Pair.gist, "'(:a)' is also a pair";
44 is f1n(:a[1, 2, 3]), Array.gist, ':a[...] constructs an Array value';
45 is f1n(:a{b => 3}), Hash.gist, ':a{...} constructs a Hash value';
82c7ae0 [t/spec] tests for :a[...] and :a{...} colonpair syntax
moritz authored Mar 20, 2010
46 }
47
48 {
49 my $p = :a[1, 2, 3];
50 is $p.key, 'a', 'correct key for :a[1, 2, 3]';
51 is $p.value.join('|'), '1|2|3', 'correct value for :a[1, 2, 3]';
52 }
53
54 {
55 my $p = :a{b => 'c'};
56 is $p.key, 'a', 'correct key for :a{ b => "c" }';
57 is $p.value.keys, 'b', 'correct value for :a{ b => "c" } (keys)';
58 is $p.value.values, 'c', 'correct value for :a{ b => "c" } (values)';
ce0e942 [t] moved pairs.t to spec/, fudged a bit, added a test
moritz authored Sep 10, 2008
59 }
60
a524b51 [t/spec]: protoobjects stringify to shortname plus parens (S12)
pmichaud authored Apr 28, 2009
61 sub f2 (:$a!) { WHAT($a) }
ce0e942 [t] moved pairs.t to spec/, fudged a bit, added a test
moritz authored Sep 10, 2008
62 {
63 my $f2 = &f2;
64
a524b51 [t/spec]: protoobjects stringify to shortname plus parens (S12)
pmichaud authored Apr 28, 2009
65 isa_ok f2(a => 42), Int, "'a => 42' is a named";
66 isa_ok f2(:a(42)), Int, "':a(42)' is a named";
09827a2 [t/spec] Some corrections, along with a little re-fudging of S02-lite…
jnthn authored Feb 6, 2010
67 isa_ok f2(:a), Bool,"':a' is a named";
54fdac8 fixing some quotes, and testing my commit powers
andy authored Feb 23, 2009
68
7aaba1f @colomon Fudge for niecza, rewrite last test to use a standard for loop.
colomon authored Dec 22, 2011
69 #?niecza skip "Action method escape:sym<&> not yet implemented"
09827a2 [t/spec] Some corrections, along with a little re-fudging of S02-lite…
jnthn authored Feb 6, 2010
70 isa_ok(&f2.(:a), Bool, "in '&f2.(:a)', ':a' is a named");
71 isa_ok $f2(:a), Bool, "in '\$f2(:a)', ':a' is a named";
72 isa_ok $f2.(:a), Bool, "in '\$f2.(:a)', ':a' is a named";
ce0e942 [t] moved pairs.t to spec/, fudged a bit, added a test
moritz authored Sep 10, 2008
73
246ed8d @coke pugs fudges
coke authored Mar 3, 2012
74 #?pugs 7 skip 'Missing required parameters'
ce0e942 [t] moved pairs.t to spec/, fudged a bit, added a test
moritz authored Sep 10, 2008
75 dies_ok { f2("a" => 42) }, "'\"a\" => 42' is a pair";
76 dies_ok { f2(("a") => 42) }, "'(\"a\") => 42' is a pair";
77 dies_ok { f2((a => 42)) }, "'(a => 42)' is a pair";
78 dies_ok { f2(("a" => 42)) }, "'(\"a\" => 42)' is a pair";
79 dies_ok { f2((:a(42))) }, "'(:a(42))' is a pair";
80 dies_ok { f2((:a)) }, "'(:a)' is a pair";
c7734e0 [t/spec] Correct a test description that ccidentally the interpolated…
jnthn authored Apr 3, 2010
81 dies_ok { &f2.((:a)) }, 'in \'&f2.((:a))\', \'(:a)\' is a pair';
189b4db [t/spec] cosmetic cleaning: remove trailing space
wollmers authored May 6, 2009
82
246ed8d @coke pugs fudges
coke authored Mar 4, 2012
83 #?pugs 4 skip 'Missing required parameters'
ce0e942 [t] moved pairs.t to spec/, fudged a bit, added a test
moritz authored Sep 10, 2008
84 dies_ok { $f2((:a)) }, "in '\$f2((:a))', '(:a)' is a pair";
85 dies_ok { $f2.((:a)) }, "in '\$f2.((:a))', '(:a)' is a pair";
86 dies_ok { $f2(((:a))) }, "in '\$f2(((:a)))', '(:a)' is a pair";
87 dies_ok { $f2.(((:a))) }, "in '\$f2.(((:a)))', '(:a)' is a pair";
88 }
89
a524b51 [t/spec]: protoobjects stringify to shortname plus parens (S12)
pmichaud authored Apr 28, 2009
90 sub f3 ($a) { WHAT($a) }
ce0e942 [t] moved pairs.t to spec/, fudged a bit, added a test
moritz authored Sep 10, 2008
91 {
92 my $pair = (a => 42);
93
a524b51 [t/spec]: protoobjects stringify to shortname plus parens (S12)
pmichaud authored Apr 28, 2009
94 isa_ok f3($pair), Pair, 'a $pair is not treated magically...';
246ed8d @coke pugs fudges
coke authored Mar 4, 2012
95 ##?pugs todo '[,]'
207f13f [t] and [t/spec]
moritz authored Dec 25, 2008
96 #?rakudo skip 'prefix:<|>'
a524b51 [t/spec]: protoobjects stringify to shortname plus parens (S12)
pmichaud authored Apr 28, 2009
97 isa_ok f3(|$pair), Int, '...but |$pair is';
ce0e942 [t] moved pairs.t to spec/, fudged a bit, added a test
moritz authored Sep 10, 2008
98 }
99
a524b51 [t/spec]: protoobjects stringify to shortname plus parens (S12)
pmichaud authored Apr 28, 2009
100 sub f4 ($a) { WHAT($a) }
ce0e942 [t] moved pairs.t to spec/, fudged a bit, added a test
moritz authored Sep 10, 2008
101 sub get_pair () { (a => 42) }
102 {
103
a524b51 [t/spec]: protoobjects stringify to shortname plus parens (S12)
pmichaud authored Apr 28, 2009
104 isa_ok f4(get_pair()), Pair, 'get_pair() is not treated magically...';
ce0e942 [t] moved pairs.t to spec/, fudged a bit, added a test
moritz authored Sep 10, 2008
105 #?rakudo skip 'reduce meta op'
a524b51 [t/spec]: protoobjects stringify to shortname plus parens (S12)
pmichaud authored Apr 28, 2009
106 isa_ok f4(|get_pair()), Int, '...but |get_pair() is';
ce0e942 [t] moved pairs.t to spec/, fudged a bit, added a test
moritz authored Sep 10, 2008
107 }
108
a524b51 [t/spec]: protoobjects stringify to shortname plus parens (S12)
pmichaud authored Apr 28, 2009
109 sub f5 ($a) { WHAT($a) }
ce0e942 [t] moved pairs.t to spec/, fudged a bit, added a test
moritz authored Sep 10, 2008
110 {
111 my @array_of_pairs = (a => 42);
112
a524b51 [t/spec]: protoobjects stringify to shortname plus parens (S12)
pmichaud authored Apr 28, 2009
113 isa_ok f5(@array_of_pairs), Array,
ce0e942 [t] moved pairs.t to spec/, fudged a bit, added a test
moritz authored Sep 10, 2008
114 'an array of pairs is not treated magically...';
1cc6e47 @coke rakudo (auto) (un)fudge
coke authored Apr 25, 2012
115 #?rakudo todo 'prefix:<|>'
7aaba1f @colomon Fudge for niecza, rewrite last test to use a standard for loop.
colomon authored Dec 22, 2011
116 #?niecza todo
a524b51 [t/spec]: protoobjects stringify to shortname plus parens (S12)
pmichaud authored Apr 28, 2009
117 isa_ok f5(|@array_of_pairs), Array, '...and |@array isn\'t either';
ce0e942 [t] moved pairs.t to spec/, fudged a bit, added a test
moritz authored Sep 10, 2008
118 }
119
a524b51 [t/spec]: protoobjects stringify to shortname plus parens (S12)
pmichaud authored Apr 28, 2009
120 sub f6 ($a) { WHAT($a) }
ce0e942 [t] moved pairs.t to spec/, fudged a bit, added a test
moritz authored Sep 10, 2008
121 {
122
123 my %hash_of_pairs = (a => "str");
124
09827a2 [t/spec] Some corrections, along with a little re-fudging of S02-lite…
jnthn authored Feb 6, 2010
125 ok (f6(%hash_of_pairs)).does(Hash), 'a hash is not treated magically...';
ce0e942 [t] moved pairs.t to spec/, fudged a bit, added a test
moritz authored Sep 10, 2008
126 #?pugs todo '[,]'
1cc6e47 @coke rakudo (auto) (un)fudge
coke authored Apr 25, 2012
127 #?rakudo todo 'reduce meta op'
7aaba1f @colomon Fudge for niecza, rewrite last test to use a standard for loop.
colomon authored Dec 22, 2011
128 #?niecza todo
a524b51 [t/spec]: protoobjects stringify to shortname plus parens (S12)
pmichaud authored Apr 28, 2009
129 isa_ok f6([,] %hash_of_pairs), Str, '...but [,] %hash is';
ce0e942 [t] moved pairs.t to spec/, fudged a bit, added a test
moritz authored Sep 10, 2008
130 }
131
a524b51 [t/spec]: protoobjects stringify to shortname plus parens (S12)
pmichaud authored Apr 28, 2009
132 sub f7 (:$bar!) { WHAT($bar) }
246ed8d @coke pugs fudges
coke authored Mar 4, 2012
133 #?pugs skip 'Missing required parameter'
ce0e942 [t] moved pairs.t to spec/, fudged a bit, added a test
moritz authored Sep 10, 2008
134 {
54fdac8 fixing some quotes, and testing my commit powers
andy authored Feb 23, 2009
135 my $bar = 'bar';
ce0e942 [t] moved pairs.t to spec/, fudged a bit, added a test
moritz authored Sep 10, 2008
136
137 dies_ok { f7($bar => 42) },
138 "variables cannot be keys of syntactical pairs (1)";
139 }
140
a524b51 [t/spec]: protoobjects stringify to shortname plus parens (S12)
pmichaud authored Apr 28, 2009
141 sub f8 (:$bar!) { WHAT($bar) }
246ed8d @coke pugs fudges
coke authored Mar 4, 2012
142 #?pugs skip 'Missing required parameter'
ce0e942 [t] moved pairs.t to spec/, fudged a bit, added a test
moritz authored Sep 10, 2008
143 {
144 my @array = <bar>;
145
146 dies_ok { f8(@array => 42) },
147 "variables cannot be keys of syntactical pairs (2)";
148 }
149
a524b51 [t/spec]: protoobjects stringify to shortname plus parens (S12)
pmichaud authored Apr 28, 2009
150 sub f9 (:$bar!) { WHAT($bar) }
246ed8d @coke pugs fudges
coke authored Mar 4, 2012
151 #?pugs skip 'Missing required parameter'
ce0e942 [t] moved pairs.t to spec/, fudged a bit, added a test
moritz authored Sep 10, 2008
152 {
153 my $arrayref = <bar>;
154
155 dies_ok { f9($arrayref => 42) },
156 "variables cannot be keys of syntactical pairs (3)";
157 }
7f29bc5 [t/spec] Add vim: lines everywhere.
kyle authored Aug 8, 2009
158
246ed8d @coke pugs fudges
coke authored Mar 4, 2012
159 #?pugs todo
345d587 [t/spec] test for RT #74732, Pair.elems
moritz authored Apr 28, 2010
160 {
161 is (a => 3).elems, 1, 'Pair.elems';
162 }
163
6f4dfd4 [pairs.t] Added tests for RT #74948.
Kodi Arfer authored Jan 9, 2011
164 # RT #74948
d3515cb @coke nom fudging.
coke authored Jul 31, 2011
165 #?DOES 32
26c1e24 Added tests for "time" and the like on the LHS of a fatarrrow.
Kodi Arfer authored Oct 18, 2010
166 {
7aaba1f @colomon Fudge for niecza, rewrite last test to use a standard for loop.
colomon authored Dec 22, 2011
167 for <
6f4dfd4 [pairs.t] Added tests for RT #74948.
Kodi Arfer authored Jan 9, 2011
168 self rand time now YOU_ARE_HERE package module class role
169 grammar my our state let temp has augment anon supersede
170 sub method submethod macro multi proto only regex token
171 rule constant enum subset
7aaba1f @colomon Fudge for niecza, rewrite last test to use a standard for loop.
colomon authored Dec 22, 2011
172 > {
173 is eval("($_ => 1).key"), $_, "Pair with '$_' as key"
174 }
26c1e24 Added tests for "time" and the like on the LHS of a fatarrrow.
Kodi Arfer authored Oct 18, 2010
175 }
176
7f29bc5 [t/spec] Add vim: lines everywhere.
kyle authored Aug 8, 2009
177 # vim: ft=perl6
Something went wrong with that request. Please try again.