Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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