Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 372 lines (325 sloc) 13.954 kb
932a1bc [gsoc_spectest] reorganization of reduce tests
Auzon authored
1 use v6;
2 use Test;
e122112 [t/spec] fix reduce-metaop.t, moritz--
moritz authored
3
932a1bc [gsoc_spectest] reorganization of reduce tests
Auzon authored
4 =begin pod
5
6 =head1 DESCRIPTION
7
8 This test tests the C<[...]> reduce metaoperator.
9
10 Reference:
11 L<"http://groups.google.de/group/perl.perl6.language/msg/bd9eb275d5da2eda">
12
13 =end pod
14
15 # L<S03/"Reduction operators">
16
17 # [...] reduce metaoperator
18 {
19 my @array = <5 -3 7 0 1 -9>;
20 my $sum = 5 + -3 + 7 + 0 + 1 + -9; # laziness :)
21
22 is(([+] @array), $sum, "[+] works");
23 is(([*] 1,2,3), (1*2*3), "[*] works");
24 is(([-] 1,2,3), (1-2-3), "[-] works");
25 is(([/] 12,4,3), (12/4/3), "[/] works");
9b6c25a [t/spec] Add simple tests for [div] and [mod].
colomon authored
26 is(([div] 12,4,3), (12 div 4 div 3), "[div] works");
932a1bc [gsoc_spectest] reorganization of reduce tests
Auzon authored
27 is(([**] 2,2,3), (2**2**3), "[**] works");
5d1999e [t/spec] a test for [%] (meta reduce modulo)
moritz authored
28 is(([%] 13,7,4), (13%7%4), "[%] works");
9b6c25a [t/spec] Add simple tests for [div] and [mod].
colomon authored
29 is(([mod] 13,7,4), (13 mod 7 mod 4), "[mod] works");
932a1bc [gsoc_spectest] reorganization of reduce tests
Auzon authored
30
31 is((~ [\+] @array), "5 2 9 9 10 1", "[\\+] works");
32 is((~ [\-] 1, 2, 3), "1 -1 -4", "[\\-] works");
33 }
34
35 {
36 is ([~] <a b c d>), "abcd", "[~] works";
37 is (~ [\~] <a b c d>), "a ab abc abcd", "[\\~] works";
38 }
39
40 {
ea847c7 @moritz remove more wrong uses of True and False as 0 and 1 (still more left); m...
moritz authored
41 ok ([<] 1, 2, 3, 4), "[<] works (1)";
42 nok ([<] 1, 3, 2, 4), "[<] works (2)";
43 ok ([>] 4, 3, 2, 1), "[>] works (1)";
44 nok ([>] 4, 2, 3, 1), "[>] works (2)";
45 ok ([==] 4, 4, 4), "[==] works (1)";
46 nok ([==] 4, 5, 4), "[==] works (2)";
c8e9e01 @sorear Fudge reduce.t for niecza
sorear authored
47 #?niecza 2 skip 'this is parsed as ![=], not good'
ea847c7 @moritz remove more wrong uses of True and False as 0 and 1 (still more left); m...
moritz authored
48 ok ([!=] 4, 5, 6), "[!=] works (1)";
49 nok ([!=] 4, 4, 4), "[!=] works (2)";
e7dbb23 [t/spec] Refudge S03-metaops/reduce.t a bit so that it works again.
colomon authored
50 }
d1ccd8b [t/spec] tests for === and =:= and their negated forms inside meta ops
moritz authored
51
e7dbb23 [t/spec] Refudge S03-metaops/reduce.t a bit so that it works again.
colomon authored
52 {
e75736f [t/spec] tests for [eq], [ne]
moritz authored
53 ok (! [eq] <a a b a>), '[eq] basic sanity (positive)';
54 ok ( [eq] <a a a a>), '[eq] basic sanity (negative)';
55 ok ( [ne] <a b c a>), '[ne] basic sanity (positive)';
56 ok (! [ne] <a a b c>), '[ne] basic sanity (negative)';
57 ok ( [lt] <a b c e>), '[lt] basic sanity (positive)';
58 ok (! [lt] <a a c e>), '[lt] basic sanity (negative)';
e7dbb23 [t/spec] Refudge S03-metaops/reduce.t a bit so that it works again.
colomon authored
59 }
e75736f [t/spec] tests for [eq], [ne]
moritz authored
60
e7dbb23 [t/spec] Refudge S03-metaops/reduce.t a bit so that it works again.
colomon authored
61 #?rakudo skip "=:= NYI"
ef1d26d @sorear Miscellaneous niecza unfudges
sorear authored
62 #?niecza skip "reduce/binding interaction issues"
e7dbb23 [t/spec] Refudge S03-metaops/reduce.t a bit so that it works again.
colomon authored
63 {
d1ccd8b [t/spec] tests for === and =:= and their negated forms inside meta ops
moritz authored
64 my ($x, $y);
65 ok ( [=:=] $x, $x, $x), '[=:=] basic sanity 1';
66 ok (not [=:=] $x, $y, $x), '[=:=] basic sanity 2';
67 ok ( [!=:=] $x, $y, $x), '[!=:=] basic sanity (positive)';
68 ok (not [!=:=] $y, $y, $x), '[!=:=] basic sanity (negative)';
69 $y := $x;
70 ok ( [=:=] $y, $x, $y), '[=:=] after binding';
e7dbb23 [t/spec] Refudge S03-metaops/reduce.t a bit so that it works again.
colomon authored
71 }
d1ccd8b [t/spec] tests for === and =:= and their negated forms inside meta ops
moritz authored
72
c8e9e01 @sorear Fudge reduce.t for niecza
sorear authored
73 #?niecza skip "=== on value types NYI"
e7dbb23 [t/spec] Refudge S03-metaops/reduce.t a bit so that it works again.
colomon authored
74 {
d1ccd8b [t/spec] tests for === and =:= and their negated forms inside meta ops
moritz authored
75 my $a = [1, 2];
76 my $b = [1, 2];
77
ea847c7 @moritz remove more wrong uses of True and False as 0 and 1 (still more left); m...
moritz authored
78 ok ([===] 1, 1, 1, 1), '[===] with literals';
79 ok ([===] $a, $a, $a), '[===] with vars (positive)';
80 nok ([===] $a, $a, [1, 2]), '[===] with vars (negative)';
9c74a37 @moritz fudge reduce.t for rakudo
moritz authored
81 #?rakudo 2 skip '[!===]'
ea847c7 @moritz remove more wrong uses of True and False as 0 and 1 (still more left); m...
moritz authored
82 ok ([!===] $a, $b, $a), '[!===] basic sanity (positive)';
83 nok ([!===] $a, $b, $b), '[!===] basic sanity (negative)';
434eb4e [t/spec] Unfudge tests for reduction meta-operator with chaining comparr...
jnthn authored
84 }
932a1bc [gsoc_spectest] reorganization of reduce tests
Auzon authored
85
434eb4e [t/spec] Unfudge tests for reduction meta-operator with chaining comparr...
jnthn authored
86 {
29b04a9 @moritz fix tests for Bool stringification
moritz authored
87 is ~ ([\<] 1, 2, 3, 4).map({+$_}), "1 1 1 1", "[\\<] works (1)";
88 is ~ ([\<] 1, 3, 2, 4).map({+$_}), "1 1 0 0", "[\\<] works (2)";
89 is ~ ([\>] 4, 3, 2, 1).map({+$_}), "1 1 1 1", "[\\>] works (1)";
90 is ~ ([\>] 4, 2, 3, 1).map({+$_}), "1 1 0 0", "[\\>] works (2)";
91 is ~ ([\==] 4, 4, 4).map({+$_}), "1 1 1", "[\\==] works (1)";
92 is ~ ([\==] 4, 5, 4).map({+$_}), "1 0 0", "[\\==] works (2)";
c8e9e01 @sorear Fudge reduce.t for niecza
sorear authored
93 #?niecza 2 skip 'this is parsed as ![=], not good'
29b04a9 @moritz fix tests for Bool stringification
moritz authored
94 is ~ ([\!=] 4, 5, 6).map({+$_}), "1 1 1", "[\\!=] works (1)";
95 is ~ ([\!=] 4, 5, 5).map({+$_}), "1 1 0", "[\\!=] works (2)";
5cb1e9f [t/spec] Fix triangle form of reduce metaop tests.
bacek authored
96 is (~ [\**] 1, 2, 3), "3 8 1", "[\\**] (right assoc) works (1)";
97 is (~ [\**] 3, 2, 0), "0 1 3", "[\\**] (right assoc) works (2)";
932a1bc [gsoc_spectest] reorganization of reduce tests
Auzon authored
98 }
99
5b5d98a @moritz [reduce.t] tests for RT #76110
moritz authored
100 # RT #76110
101 {
102 is ~([\+] [\+] 1 xx 5), '1 3 6 10 15', 'two nested [\+]';
c8e9e01 @sorear Fudge reduce.t for niecza
sorear authored
103 #?niecza skip 'unary [] does not context yet'
5b5d98a @moritz [reduce.t] tests for RT #76110
moritz authored
104 is ([+] [1, 2, 3, 4]), 4, '[+] does not flatten []-arrays';
105 }
106
ef1d26d @sorear Miscellaneous niecza unfudges
sorear authored
107 #?niecza skip '[macro]'
932a1bc [gsoc_spectest] reorganization of reduce tests
Auzon authored
108 {
8f9a119 [t/] unify compartmentalized undef and Object concepts into Mu
lwall authored
109 my @array = (Mu, Mu, 3, Mu, 5);
932a1bc [gsoc_spectest] reorganization of reduce tests
Auzon authored
110 is ([//] @array), 3, "[//] works";
111 is ([orelse] @array), 3, "[orelse] works";
112 }
113
ef1d26d @sorear Miscellaneous niecza unfudges
sorear authored
114 #?niecza skip '[macro]'
932a1bc [gsoc_spectest] reorganization of reduce tests
Auzon authored
115 {
8f9a119 [t/] unify compartmentalized undef and Object concepts into Mu
lwall authored
116 my @array = (Mu, Mu, 0, 3, Mu, 5);
932a1bc [gsoc_spectest] reorganization of reduce tests
Auzon authored
117 is ([||] @array), 3, "[||] works";
118 is ([or] @array), 3, "[or] works";
119
8f9a119 [t/] unify compartmentalized undef and Object concepts into Mu
lwall authored
120 # Mu as well as [//] should work too, but testing it like
932a1bc [gsoc_spectest] reorganization of reduce tests
Auzon authored
121 # this would presumably emit warnings when we have them.
122 is (~ [\||] 0, 0, 3, 4, 5), "0 0 3 3 3", "[\\||] works";
123 }
124
ef1d26d @sorear Miscellaneous niecza unfudges
sorear authored
125 #?niecza skip '[macro]'
fc7413f [t/spec] Tests for [&&] and [and]. Patch courtesy of (Alex Kapranoff)++.
jnthn authored
126 {
127 my @array = (Mu, Mu, 0, 3, Mu, 5);
128 my @array1 = (2, 3, 4);
129 nok ([&&] @array), "[&&] works with 1 false";
130 is ([&&] @array1), 4, "[&&] works";
131 nok ([and] @array), "[and] works with 1 false";
132 is ([and] @array1), 4, "[and] works";
133 }
134
bc058f2 [STD] improve parsing of reduceops
lwall authored
135 # not currently legal without an infix subscript operator
136 # {
137 # my $hash = {a => {b => {c => {d => 42, e => 23}}}};
138 # is try { [.{}] $hash, <a b c d> }, 42, '[.{}] works';
139 # }
140 #
141 # {
142 # my $hash = {a => {b => 42}};
143 # is ([.{}] $hash, <a b>), 42, '[.{}] works two levels deep';
144 # }
145 #
146 # {
147 # my $arr = [[[1,2,3],[4,5,6]],[[7,8,9],[10,11,12]]];
148 # is ([.[]] $arr, 1, 0, 2), 9, '[.[]] works';
149 # }
932a1bc [gsoc_spectest] reorganization of reduce tests
Auzon authored
150
151 {
152 # 18:45 < autrijus> hm, I found a way to easily do linked list consing in Perl6
153 # 18:45 < autrijus> [=>] 1..10;
154 my $list = [=>] 1,2,3;
ed68273 [t/spec] remove usage of try as a function
moritz authored
155 is $list.key, 1, "[=>] works (1)";
156 is (try {$list.value.key}), 2, "[=>] works (2)";
157 is (try {$list.value.value}), 3, "[=>] works (3)";
932a1bc [gsoc_spectest] reorganization of reduce tests
Auzon authored
158 }
159
c8e9e01 @sorear Fudge reduce.t for niecza
sorear authored
160 #?niecza skip 'huh?'
932a1bc [gsoc_spectest] reorganization of reduce tests
Auzon authored
161 {
21768a7 [t/spec] clean up and fudge reduce-metaop.t for rakudo.
moritz authored
162 my @array = <5 -3 7 0 1 -9>;
163 # according to http://irclog.perlgeek.de/perl6/2008-09-10#i_560910
164 # [,] returns a scalar (holding an Array)
165 my $count = 0;
166 $count++ for [,] @array;
9c74a37 @moritz fudge reduce.t for rakudo
moritz authored
167 #?rakudo todo 'item context'
21768a7 [t/spec] clean up and fudge reduce-metaop.t for rakudo.
moritz authored
168 is $count, 1, '[,] returns a single Array';
a246cb9 [t/spec] correct a test for [,], and unfudge a few for rakudo
moritz authored
169 ok ([,] @array) ~~ Positional, '[,] returns something Positional';
932a1bc [gsoc_spectest] reorganization of reduce tests
Auzon authored
170 }
171
172 # Following two tests taken verbatim from former t/operators/reduce.t
c8e9e01 @sorear Fudge reduce.t for niecza
sorear authored
173 #?niecza 2 skip 'These are hyperop tests!'
932a1bc [gsoc_spectest] reorganization of reduce tests
Auzon authored
174 lives_ok({my @foo = [1..3] >>+<< [1..3] >>+<< [1..3]},'Sanity Check');
9c74a37 @moritz fudge reduce.t for rakudo
moritz authored
175 #?rakudo todo 'reduced hyper op'
932a1bc [gsoc_spectest] reorganization of reduce tests
Auzon authored
176 lives_ok({my @foo = [>>+<<] ([1..3],[1..3],[1..3])},'Parse [>>+<<]');
177
178 # Check that user defined infix ops work with [...], too.
21768a7 [t/spec] clean up and fudge reduce-metaop.t for rakudo.
moritz authored
179 #?pugs todo 'bug'
8de8af6 [t/spec] partially fudge reduce.t for rakudo
moritz authored
180 #?rakudo skip 'reduce of user defined op'
21768a7 [t/spec] clean up and fudge reduce-metaop.t for rakudo.
moritz authored
181 {
c8e9e01 @sorear Fudge reduce.t for niecza
sorear authored
182 sub infix:<more_than_plus>($a, $b) { $a + $b + 1 }
d1ccd8b [t/spec] tests for === and =:= and their negated forms inside meta ops
moritz authored
183 is (try { [more_than_plus] 1, 2, 3 }), 8, "[...] reduce metaop works on user defined ops";
21768a7 [t/spec] clean up and fudge reduce-metaop.t for rakudo.
moritz authored
184 }
932a1bc [gsoc_spectest] reorganization of reduce tests
Auzon authored
185
f148336 [STD vs t] user-defined prefix, infix, and postfix ops now derive new la...
lwall authored
186 # {
187 # my $arr = [ 42, [ 23 ] ];
188 # $arr[1][1] = $arr;
189 #
190 # is try { [.[]] $arr, 1, 1, 1, 1, 1, 0 }, 23, '[.[]] works with infinite data structures';
191 # }
192 #
193 # {
194 # my $hash = {a => {b => 42}};
195 # $hash<a><c> = $hash;
196 #
197 # is try { [.{}] $hash, <a c a c a b> }, 42, '[.{}] works with infinite data structures';
198 # }
932a1bc [gsoc_spectest] reorganization of reduce tests
Auzon authored
199
200 # L<S03/"Reduction operators"/"Among the builtin operators, [+]() returns 0 and [*]() returns 1">
201
c8e9e01 @sorear Fudge reduce.t for niecza
sorear authored
202 #?niecza skip '[*] identity'
21768a7 [t/spec] clean up and fudge reduce-metaop.t for rakudo.
moritz authored
203 is( ([*]()), 1, "[*]() returns 1");
204 is( ([+]()), 0, "[+]() returns 0");
932a1bc [gsoc_spectest] reorganization of reduce tests
Auzon authored
205
2d7d862 [t/spec] Add a few tests for the one-argument case.
colomon authored
206 is( ([*] 41), 41, "[*] 41 returns 41");
207 is( ([*] 42), 42, "[*] 42 returns 42");
0e61dff [t/spec] Add a few more tests for the one-argument case.
colomon authored
208 is( ~([\*] 42), "42", "[\*] 42 returns (42)");
2d7d862 [t/spec] Add a few tests for the one-argument case.
colomon authored
209 is( ([~] 'towel'), 'towel', "[~] 'towel' returns 'towel'");
210 is( ([~] 'washcloth'), 'washcloth', "[~] 'washcloth' returns 'washcloth'");
0e61dff [t/spec] Add a few more tests for the one-argument case.
colomon authored
211 is( ([\~] 'towel'), 'towel', "[\~] 'towel' returns 'towel'");
c8e9e01 @sorear Fudge reduce.t for niecza
sorear authored
212 #?niecza skip 'Iterable'
f9ed5f4 [reduce.t] fix parsefail
lwall authored
213 ok( ([\~] 'towel') ~~ Iterable, "[\~] 'towel' returns something Iterable");
2d7d862 [t/spec] Add a few tests for the one-argument case.
colomon authored
214 is( ([<] 42), Bool::True, "[<] 42 returns true");
ea847c7 @moritz remove more wrong uses of True and False as 0 and 1 (still more left); m...
moritz authored
215 is( ~([\<] 42), ~True, "[\<] 42 returns '1'");
c8e9e01 @sorear Fudge reduce.t for niecza
sorear authored
216 #?niecza skip 'Iterable'
0e61dff [t/spec] Add a few more tests for the one-argument case.
colomon authored
217 ok( ([\<] 42) ~~ Iterable, "[\<] 42 returns something Iterable");
2d7d862 [t/spec] Add a few tests for the one-argument case.
colomon authored
218
9e9686f [t/spec] replace .batch($x) with .[^$x]
moritz authored
219 is( ([\*] 1..*).[^10].join(', '), '1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800',
09a80e6 [t/spec] Add two tests for lazy triangle reduce.
colomon authored
220 'triangle reduce is lazy');
ef1d26d @sorear Miscellaneous niecza unfudges
sorear authored
221 #?niecza skip 'Str cmp Inf'
9e9686f [t/spec] replace .batch($x) with .[^$x]
moritz authored
222 is( ([\R~] 'a'..*).[^8].join(', '), 'a, ba, cba, dcba, edcba, fedcba, gfedcba, hgfedcba',
09a80e6 [t/spec] Add two tests for lazy triangle reduce.
colomon authored
223 'triangle reduce is lazy');
224
748c769 Additions and unfudging for &infix:<^^> and &infix:<xor>.
Kodi Arfer authored
225 # RT #65164 implement [^^]
c8e9e01 @sorear Fudge reduce.t for niecza
sorear authored
226 #?niecza skip '^^'
9c74a37 @moritz fudge reduce.t for rakudo
moritz authored
227 #?rakudo skip '[^^]'
f80ef63 [t/spec] Tests for RT #65164
kyle authored
228 {
de5c0ff [reduce.t] Edited [^^] tests so RT #77442 isn't a prerequisite.
Kodi Arfer authored
229 is ([^^] 0, 42), 42, '[^^] works (one of two true)';
230 is ([^^] 42, 0), 42, '[^^] works (one of two true)';
231 ok ! ([^^] 1, 42), '[^^] works (two true)';
232 ok ! ([^^] 0, 0), '[^^] works (two false)';
f80ef63 [t/spec] Tests for RT #65164
kyle authored
233
de5c0ff [reduce.t] Edited [^^] tests so RT #77442 isn't a prerequisite.
Kodi Arfer authored
234 ok ! ([^^] 0, 0, 0), '[^^] works (three false)';
9c74a37 @moritz fudge reduce.t for rakudo
moritz authored
235 #?rakudo 2 todo '[^^]'
de5c0ff [reduce.t] Edited [^^] tests so RT #77442 isn't a prerequisite.
Kodi Arfer authored
236 ok ! ([^^] 5, 9, 17), '[^^] works (three true)';
f80ef63 [t/spec] Tests for RT #65164
kyle authored
237
de5c0ff [reduce.t] Edited [^^] tests so RT #77442 isn't a prerequisite.
Kodi Arfer authored
238 is ([^^] 5, 9, 0), (5 ^^ 9 ^^ 0), '[^^] mix 1';
239 is ([^^] 5, 0, 17), (5 ^^ 0 ^^ 17), '[^^] mix 2';
240 is ([^^] 0, 9, 17), (0 ^^ 9 ^^ 17), '[^^] mix 3';
241 is ([^^] 5, 0, 0), (5 ^^ 0 ^^ 0), '[^^] mix 4';
242 is ([^^] 0, 9, 0), (0 ^^ 9 ^^ 0), '[^^] mix 5';
243 is ([^^] 0, 0, 17), (0 ^^ 0 ^^ 17), '[^^] mix 6';
e9cdf15 @felliott add tests for RT #65164 (chained-xor reduce: [^^])
felliott authored
244
689122d [reduce.t] Added test for [^^] on an empty list (thundergnat++).
Kodi Arfer authored
245 nok ([^^] ()), 'reduce empty list ok';
246
e9cdf15 @felliott add tests for RT #65164 (chained-xor reduce: [^^])
felliott authored
247 # test False / undefined things
248 my $msg1 = 'reduce [^^] false variable test';
249 my $msg2 = 'infix ^^ false variable test';
250 for (0, '0', '', Bool::False, Any, Mu, Nil) -> $undef {
de5c0ff [reduce.t] Edited [^^] tests so RT #77442 isn't a prerequisite.
Kodi Arfer authored
251 ok ( [^^] $undef, $undef, $undef, 5 ), "|{$undef.perl}| $msg1 \#1";
252 nok ( [^^] 1, 2, $undef, 3, $undef ), "|{$undef.perl}| $msg1 \#2";
253 nok ( [^^] $undef, $undef, 1, 5 ), "|{$undef.perl}| $msg1 \#3";
254 nok ( [^^] 1, $undef, $undef, 5 ), "|{$undef.perl}| $msg1 \#4";
255 ok ( [^^] $undef, $undef, 2, $undef ), "|{$undef.perl}| $msg1 \#5";
256 nok ( [^^] $undef, $undef, $undef ), "|{$undef.perl}| $msg1 \#6";
257 nok ( [^^] $undef, $undef ), "|{$undef.perl}| $msg1 \#7";
258 ok ( [^^] $undef, 1 ), "|{$undef.perl}| $msg1 \#8";
259 ok ( [^^] 1, $undef ), "|{$undef.perl}| $msg1 \#9";
260 nok ( [^^] $undef ), "|{$undef.perl}| $msg1 \#10";
e9cdf15 @felliott add tests for RT #65164 (chained-xor reduce: [^^])
felliott authored
261 ok ( $undef ^^ $undef ^^ $undef ^^ 5 ), "|{$undef.perl}| $msg2 \#1";
262 nok ( 1 ^^ 2 ^^ $undef ^^ 3 ^^ $undef ), "|{$undef.perl}| $msg2 \#2";
263 nok ( $undef ^^ $undef ^^ 1 ^^ 5 ), "|{$undef.perl}| $msg2 \#3";
264 nok ( 1 ^^ $undef ^^ $undef ^^ 5 ), "|{$undef.perl}| $msg2 \#4";
265 ok ( $undef ^^ $undef ^^ 2 ^^ $undef ), "|{$undef.perl}| $msg2 \#5";
266 nok ( $undef ^^ $undef ^^ $undef ), "|{$undef.perl}| $msg2 \#6";
267 nok ( $undef ^^ $undef ), "|{$undef.perl}| $msg2 \#7";
268 ok ( $undef ^^ 1 ), "|{$undef.perl}| $msg2 \#8";
269 ok ( 1 ^^ $undef ), "|{$undef.perl}| $msg2 \#9";
270 }
271
272 # test numericy true things
273 $msg1 = 'reduce [^^] true numbery variable test';
274 $msg2 = 'infix ^^ true numbery variable test';
275 for (1, -147, pi, Bool::True) -> $def {
de5c0ff [reduce.t] Edited [^^] tests so RT #77442 isn't a prerequisite.
Kodi Arfer authored
276 nok ( [^^] 0, 0, $def, 3, $def ), "|{$def.perl}| $msg1 \#1";
277 nok ( [^^] $def, $def, 0 ), "|{$def.perl}| $msg1 \#2";
278 nok ( [^^] 1, $def, Any, 5 ), "|{$def.perl}| $msg1 \#3";
279 ok ( [^^] $def, 0, 0, 0 ) == $def, "|{$def.perl}| $msg1 \#4";
280 ok ( [^^] Any, Any, Any, $def ) == $def, "|{$def.perl}| $msg1 \#5";
281 nok ( [^^] $def, $def ), "|{$def.perl}| $msg1 \#6";
282 ok ( [^^] $def, 0 ) == $def, "|{$def.perl}| $msg1 \#7";
283 ok ( [^^] 0, $def ) == $def, "|{$def.perl}| $msg1 \#8";
284 ok ( [^^] $def ), "|{$def.perl}| $msg1 \#9";
e9cdf15 @felliott add tests for RT #65164 (chained-xor reduce: [^^])
felliott authored
285 nok ( 0 ^^ 0 ^^ $def ^^ 3 ^^ $def ), "|{$def.perl}| $msg2 \#1";
286 nok ( $def ^^ $def ^^ 0 ), "|{$def.perl}| $msg2 \#2";
287 nok ( 1 ^^ $def ^^ Any ^^ 5 ), "|{$def.perl}| $msg2 \#3";
288 ok ( $def ^^ 0 ^^ 0 ^^ 0 ) == $def, "|{$def.perl}| $msg2 \#4";
289 ok ( Any ^^ Any ^^ Any ^^ $def ) == $def,"|{$def.perl}| $msg2 \#5";
290 nok ( $def ^^ $def ), "|{$def.perl}| $msg2 \#6";
291 ok ( $def ^^ 0 ) == $def, "|{$def.perl}| $msg2 \#7";
292 ok ( 0 ^^ $def ) == $def, "|{$def.perl}| $msg2 \#8";
293 }
294
295 # test stringy true things
296 $msg1 = 'reduce [^^] true string variable test';
297 $msg2 = 'infix ^^ true string variable test';
298 for ('no', 'Bob', '10', 'False') -> $def {
de5c0ff [reduce.t] Edited [^^] tests so RT #77442 isn't a prerequisite.
Kodi Arfer authored
299 nok ( [^^] $def, $def, $def, 'string' ), "|{$def.perl}| $msg1 \#1";
300 nok ( [^^] '', '', $def, 'str', $def ), "|{$def.perl}| $msg1 \#2";
301 nok ( [^^] $def, $def,'' ), "|{$def.perl}| $msg1 \#3";
302 nok ( [^^] 1, $def, Any, 5 ), "|{$def.perl}| $msg1 \#4";
303 ok ( [^^] $def, '', '', '' ) eq $def, "|{$def.perl}| $msg1 \#5";
304 ok ( [^^] Any, Any, Any, $def ) eq $def, "|{$def.perl}| $msg1 \#6";
305 nok ( [^^] $def, $def ), "|{$def.perl}| $msg1 \#7";
306 ok ( [^^] $def, '' ) eq $def, "|{$def.perl}| $msg1 \#8";
307 ok ( [^^] '', $def ) eq $def, "|{$def.perl}| $msg1 \#9";
308 ok ( [^^] $def ) eq $def, "|{$def.perl}| $msg1 \#10";
e9cdf15 @felliott add tests for RT #65164 (chained-xor reduce: [^^])
felliott authored
309 nok ( $def ^^ $def ^^ $def ^^ 'string' ), "|{$def.perl}| $msg2 \#1";
310 nok ( '' ^^ '' ^^ $def ^^ 'str' ^^ $def ),"|{$def.perl}| $msg2 \#2";
311 nok ( $def ^^ $def ^^'' ), "|{$def.perl}| $msg2 \#3";
312 nok ( 1 ^^ $def ^^ Any ^^ 5 ), "|{$def.perl}| $msg2 \#4";
313 ok ( $def ^^ '' ^^ '' ^^ '' ) eq $def, "|{$def.perl}| $msg2 \#5";
314 ok ( Any ^^ Any ^^ Any ^^ $def ) eq $def,"|{$def.perl}| $msg2 \#6";
315 nok ( $def ^^ $def ), "|{$def.perl}| $msg2 \#7";
316 ok ( $def ^^ '' ) eq $def, "|{$def.perl}| $msg2 \#8";
317 ok ( '' ^^ $def ) eq $def, "|{$def.perl}| $msg2 \#9";
318 }
319
748c769 Additions and unfudging for &infix:<^^> and &infix:<xor>.
Kodi Arfer authored
320 is (join ', ', [\^^] False, 0, 5, '', False, 16, 0, Any, "hello", False),
321 (join ', ', False, 0, 5, 5, 5, False, False, False, False, False),
322 '[\^^]';
323 is (join ', ', [\xor] 'xyzzy', Int, 0.0, '', False, 'plugh', 4, 2, 'xyzzy'),
324 (join ', ', 'xyzzy', 'xyzzy', 'xyzzy', 'xyzzy', 'xyzzy', False, False, False, False),
325 '[\xor]';
f80ef63 [t/spec] Tests for RT #65164
kyle authored
326 }
327
f890121 @felliott [reduce.t] add new fudged tests for orelse; refudge existing tests
felliott authored
328 # RT 57976 implement orelse
c8e9e01 @sorear Fudge reduce.t for niecza
sorear authored
329 #?niecza skip 'huh? these are macros'
9c74a37 @moritz fudge reduce.t for rakudo
moritz authored
330 #?rakudo skip 'orelse'
f890121 @felliott [reduce.t] add new fudged tests for orelse; refudge existing tests
felliott authored
331 {
332
333 is (join ', ', [\//] Any, 0, 1),
334 (join ', ', 'Any()', 0, 0),
335 '[\orelse]';
336 is (join ', ', [\orelse] Any, 0, 1),
337 (join ', ', 'Any()', 0, 0),
338 '[\orelse]';
339
340 }
341
65d1a8d [t/spec] tests for RT #75234, using a metaop in one class hides it from ...
moritz authored
342 # RT #75234
343 # rakudo had a problem where once-used meta operators weren't installed
344 # in a sufficiently global location, so using a meta operator in class once
345 # makes it unusable further on
c8e9e01 @sorear Fudge reduce.t for niecza
sorear authored
346 #?niecza skip 'gather for'
65d1a8d [t/spec] tests for RT #75234, using a metaop in one class hides it from ...
moritz authored
347 {
348 class A {
349 method m { return [~] gather for ^3 {take 'a'} }
350 }
351 class B {
352 method n { return [~] gather for ^4 {take 'b'}}
353 }
354 is A.new.m, 'aaa', '[~] works in first class';
355 is B.new.n, 'bbbb', '[~] works in second class';
356 is ([~] 1, 2, 5), '125', '[~] works outside class';
357 }
358
c5240b2 @kyleha [reduce] Test for RT 82210: Misparse of metaop with immediate ()
kyleha authored
359 #?rakudo todo 'RT 82210'
c8e9e01 @sorear Fudge reduce.t for niecza
sorear authored
360 #?niecza skip 'Range.Numeric'
c5240b2 @kyleha [reduce] Test for RT 82210: Misparse of metaop with immediate ()
kyleha authored
361 ok [+](1..10) + 0 == ([+] 1..10) + 0,
362 'a listop with immediate () is a function call (RT 82210)';
363
763ffeb @tadzik Test for RT #99942
tadzik authored
364 # RT #99942
365 {
366 sub rt99942 { [+] @_ };
367 is rt99942(1, 42), 43, 'RT #99942'
368 }
369
e76dd4c @moritz s/done_testing/done/ as per recent S24 changes
moritz authored
370 done;
4acefb9 [t/spec] unfudge [//] and [||] tests for rakudo
moritz authored
371 # vim: ft=perl6
Something went wrong with that request. Please try again.