Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 434 lines (331 sloc) 12.625 kb
82ba44c [spec] started to move junction tests (and upate POD). Much more work ne...
moritz authored
1 use v6;
2
3 use Test;
4
a7e1209 @coke Add a test for RT #101124
coke authored
5 plan 105;
82ba44c [spec] started to move junction tests (and upate POD). Much more work ne...
moritz authored
6
7 =begin pod
8
9 Misc. Junction tests
10
11 =end pod
12
fc2707f (un)fudge tests
kboga authored
13 # RT #64184
14 {
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
15 isa-ok any(6,7), Junction;
fc2707f (un)fudge tests
kboga authored
16 is any(6,7).WHAT.gist, Junction.gist, 'junction.WHAT works';
17 }
3f05e7f [t/spec] identifying a junction causes Null PMC
kyle authored
18
e97f6d5 [t/spec] avoid autohreading through ok()
moritz authored
19 # avoid auto-threading on ok()
0836cea @coke nom fudging
coke authored
20 #?DOES 1
8f9a119 [t/] unify compartmentalized undef and Object concepts into Mu
lwall authored
21 sub jok(Mu $condition, $msg?) { ok ?($condition), $msg };
e97f6d5 [t/spec] avoid autohreading through ok()
moritz authored
22
82ba44c [spec] started to move junction tests (and upate POD). Much more work ne...
moritz authored
23 # L<S03/Junctive operators>
24 # L<S09/Junctions>
25 {
26
13cc9c4 [t/spec] 71 typos in 32 files.
Util authored
27 # initialize them all to empty strings
82ba44c [spec] started to move junction tests (and upate POD). Much more work ne...
moritz authored
28 my $a = '';
29 my $b = '';
30 my $c = '';
31
32 # make sure they all match to an empty string
e97f6d5 [t/spec] avoid autohreading through ok()
moritz authored
33 jok('' eq ($a & $b & $c), 'junction of ($a & $b & $c) matches an empty string');
34 jok('' eq all($a, $b, $c), 'junction of all($a, $b, $c) matches an empty string');
82ba44c [spec] started to move junction tests (and upate POD). Much more work ne...
moritz authored
35
36 # give $a a value
37 $a = 'a';
38
39 # make sure that at least one of them matches 'a'
e97f6d5 [t/spec] avoid autohreading through ok()
moritz authored
40 jok('a' eq ($b | $c | $a), 'junction of ($b | $c | $a) matches at least one "a"');
41 jok('a' eq any($b, $c, $a), 'junction of any($b, $c, $a) matches at least one "a"');
82ba44c [spec] started to move junction tests (and upate POD). Much more work ne...
moritz authored
42
e97f6d5 [t/spec] avoid autohreading through ok()
moritz authored
43 jok('' eq ($b | $c | $a), 'junction of ($b | $c | $a) matches at least one empty string');
44 jok('' eq any($b, $c, $a), 'junction of any($b, $c, $a) matches at least one empty string');
82ba44c [spec] started to move junction tests (and upate POD). Much more work ne...
moritz authored
45
46 # make sure that ~only~ one of them matches 'a'
e97f6d5 [t/spec] avoid autohreading through ok()
moritz authored
47 jok('a' eq ($b ^ $c ^ $a), 'junction of ($b ^ $c ^ $a) matches at ~only~ one "a"');
48 jok('a' eq one($b, $c, $a), 'junction of one($b, $c, $a) matches at ~only~ one "a"');
82ba44c [spec] started to move junction tests (and upate POD). Much more work ne...
moritz authored
49
50 # give $b a value
51 $b = 'a';
52
53 # now this will fail
e97f6d5 [t/spec] avoid autohreading through ok()
moritz authored
54 jok('a' ne ($b ^ $c ^ $a), 'junction of ($b ^ $c ^ $a) matches at more than one "a"');
82ba44c [spec] started to move junction tests (and upate POD). Much more work ne...
moritz authored
55
56 # change $b and give $c a value
57 $b = 'b';
58 $c = 'c';
59
e97f6d5 [t/spec] avoid autohreading through ok()
moritz authored
60 jok('a' eq ($b ^ $c ^ $a), 'junction of ($b ^ $c ^ $a) matches at ~only~ one "a"');
61 jok('b' eq ($a ^ $b ^ $c), 'junction of ($a ^ $b ^ $c) matches at ~only~ one "b"');
62 jok('c' eq ($c ^ $a ^ $b), 'junction of ($c ^ $a ^ $b) matches at ~only~ one "c"');
82ba44c [spec] started to move junction tests (and upate POD). Much more work ne...
moritz authored
63
e97f6d5 [t/spec] avoid autohreading through ok()
moritz authored
64 jok('a' eq ($b | $c | $a), 'junction of ($b | $c | $a) matches at least one "a"');
65 jok('b' eq ($a | $b | $c), 'junction of ($a | $b | $c) matches at least one "b"');
66 jok('c' eq ($c | $a | $b), 'junction of ($c | $a | $b) matches at least one "c"');
82ba44c [spec] started to move junction tests (and upate POD). Much more work ne...
moritz authored
67
68
69 # test junction to junction
e97f6d5 [t/spec] avoid autohreading through ok()
moritz authored
70 jok(('a' | 'b' | 'c') eq ($a & $b & $c), 'junction ("a" | "b" | "c") matches junction ($a & $b & $c)');
71 jok(('a' & 'b' & 'c') eq ($a | $b | $c), 'junction ("a" & "b" & "c") matches junction ($a | $b | $c)');
82ba44c [spec] started to move junction tests (and upate POD). Much more work ne...
moritz authored
72
73 # mix around variables and literals
74
e97f6d5 [t/spec] avoid autohreading through ok()
moritz authored
75 jok(($a & 'b' & 'c') eq ('a' | $b | $c), 'junction ($a & "b" & "c") matches junction ("a" | $b | $c)');
76 jok(($a & 'b' & $c) eq ('a' | $b | 'c'), 'junction ($a & "b" & $c) matches junction ("a" | $b | "c")');
82ba44c [spec] started to move junction tests (and upate POD). Much more work ne...
moritz authored
77
78 }
79
80 # same tests, but with junctions as variables
81 {
13cc9c4 [t/spec] 71 typos in 32 files.
Util authored
82 # initialize them all to empty strings
82ba44c [spec] started to move junction tests (and upate POD). Much more work ne...
moritz authored
83 my $a = '';
84 my $b = '';
85 my $c = '';
86
97213bc @sorear Fudge and defossilize S03-junctions/misc
sorear authored
87 my Mu $all_of_them = $a & $b & $c;
e97f6d5 [t/spec] avoid autohreading through ok()
moritz authored
88 jok('' eq $all_of_them, 'junction variable of ($a & $b & $c) matches and empty string');
82ba44c [spec] started to move junction tests (and upate POD). Much more work ne...
moritz authored
89
90 $a = 'a';
91
97213bc @sorear Fudge and defossilize S03-junctions/misc
sorear authored
92 my Mu $any_of_them = $b | $c | $a;
e97f6d5 [t/spec] avoid autohreading through ok()
moritz authored
93 jok('a' eq $any_of_them, 'junction variable of ($b | $c | $a) matches at least one "a"');
94 jok('' eq $any_of_them, 'junction variable of ($b | $c | $a) matches at least one empty string');
82ba44c [spec] started to move junction tests (and upate POD). Much more work ne...
moritz authored
95
97213bc @sorear Fudge and defossilize S03-junctions/misc
sorear authored
96 my Mu $one_of_them = $b ^ $c ^ $a;
e97f6d5 [t/spec] avoid autohreading through ok()
moritz authored
97 jok('a' eq $one_of_them, 'junction variable of ($b ^ $c ^ $a) matches at ~only~ one "a"');
82ba44c [spec] started to move junction tests (and upate POD). Much more work ne...
moritz authored
98
99 $b = 'a';
100
101 {
97213bc @sorear Fudge and defossilize S03-junctions/misc
sorear authored
102 my Mu $one_of_them = $b ^ $c ^ $a;
e97f6d5 [t/spec] avoid autohreading through ok()
moritz authored
103 jok('a' ne $one_of_them, 'junction variable of ($b ^ $c ^ $a) matches at more than one "a"');
82ba44c [spec] started to move junction tests (and upate POD). Much more work ne...
moritz authored
104 }
105
106 $b = 'b';
107 $c = 'c';
108
109 {
97213bc @sorear Fudge and defossilize S03-junctions/misc
sorear authored
110 my Mu $one_of_them = $b ^ $c ^ $a;
e97f6d5 [t/spec] avoid autohreading through ok()
moritz authored
111 jok('a' eq $one_of_them, 'junction of ($b ^ $c ^ $a) matches at ~only~ one "a"');
112 jok('b' eq $one_of_them, 'junction of ($a ^ $b ^ $c) matches at ~only~ one "b"');
113 jok('c' eq $one_of_them, 'junction of ($c ^ $a ^ $b) matches at ~only~ one "c"');
82ba44c [spec] started to move junction tests (and upate POD). Much more work ne...
moritz authored
114 }
115
116 {
97213bc @sorear Fudge and defossilize S03-junctions/misc
sorear authored
117 my Mu $any_of_them = $b | $c | $a;
e97f6d5 [t/spec] avoid autohreading through ok()
moritz authored
118 jok('a' eq $any_of_them, 'junction of ($b | $c | $a) matches at least one "a"');
119 jok('b' eq $any_of_them, 'junction of ($a | $b | $c) matches at least one "b"');
120 jok('c' eq $any_of_them, 'junction of ($c | $a | $b) matches at least one "c"');
82ba44c [spec] started to move junction tests (and upate POD). Much more work ne...
moritz authored
121 }
122
123 }
124
125 {
97213bc @sorear Fudge and defossilize S03-junctions/misc
sorear authored
126 my Mu $j = 1 | 2;
82ba44c [spec] started to move junction tests (and upate POD). Much more work ne...
moritz authored
127 $j = 5;
128 is($j, 5, 'reassignment of junction variable');
129 }
130
131 {
97213bc @sorear Fudge and defossilize S03-junctions/misc
sorear authored
132 my Mu $j;
133 my Mu $k;
82ba44c [spec] started to move junction tests (and upate POD). Much more work ne...
moritz authored
134
135 $j = 1|2;
4debe16 @moritz more Type() -> (Type) gistification
moritz authored
136 is(WHAT($j).gist, '(Junction)', 'basic junction type reference test');
82ba44c [spec] started to move junction tests (and upate POD). Much more work ne...
moritz authored
137
138 $k=$j;
4debe16 @moritz more Type() -> (Type) gistification
moritz authored
139 is(WHAT($k).gist, '(Junction)', 'assignment preserves reference');
82ba44c [spec] started to move junction tests (and upate POD). Much more work ne...
moritz authored
140 }
141
142
143 =begin description
144
145 Tests junction examples from Synopsis 03
146
147 j() is used to convert a junction to canonical string form, currently
148 just using .perl until a better approach presents itself.
149
150 =end description
151
eda6db1 [t/spec] move smartlinks from POD to ordinary comments
moritz authored
152 # L<S03/Junctive operators>
153
82ba44c [spec] started to move junction tests (and upate POD). Much more work ne...
moritz authored
154 # Canonical stringification of a junction
8f9a119 [t/] unify compartmentalized undef and Object concepts into Mu
lwall authored
155 sub j (Mu $j) { return $j.perl }
82ba44c [spec] started to move junction tests (and upate POD). Much more work ne...
moritz authored
156
157 {
158 # L<S03/Junctive operators/They thread through operations>
97213bc @sorear Fudge and defossilize S03-junctions/misc
sorear authored
159 my Mu $got;
160 my Mu $want;
82ba44c [spec] started to move junction tests (and upate POD). Much more work ne...
moritz authored
161 $got = ((1|2|3)+4);
162 $want = (5|6|7);
163 is( j($got), j($want), 'thread + returning junctive result');
164
165 $got = ((1|2) + (3&4));
166 $want = ((4|5) & (5|6));
167 is( j($got), j($want), 'thread + returning junctive combination of results');
168
169 # L<S03/Junctive operators/This opens doors for constructions like>
170 # unless $roll == any(1..6) { print "Invalid roll" }
648ae66 [spec] fudged S03-junctions/misc.t
moritz authored
171 my $roll;
172 my $note;
82ba44c [spec] started to move junction tests (and upate POD). Much more work ne...
moritz authored
173 $roll = 3; $note = '';
174 unless $roll == any(1..6) { $note = "Invalid roll"; };
175 is($note, "", 'any() junction threading ==');
176
177 $roll = 7; $note = '';
178 unless $roll == any(1..6) { $note = "Invalid roll"; };
179 is($note, "Invalid roll", 'any() junction threading ==');
180
181 # if $roll == 1|2|3 { print "Low roll" }
182 $roll = 4; $note = '';
183 if $roll == 1|2|3 { $note = "Low roll" }
184 is($note, "", '| junction threading ==');
185
186 $roll = 2; $note = '';
187 if $roll == 1|2|3 { $note = "Low roll" }
188 is($note, "Low roll", '| junction threading ==');
d0da223 [spec]: Unfudge some junction tests for Rakudo.
pmichaud authored
189 }
82ba44c [spec] started to move junction tests (and upate POD). Much more work ne...
moritz authored
190
d0da223 [spec]: Unfudge some junction tests for Rakudo.
pmichaud authored
191 {
82ba44c [spec] started to move junction tests (and upate POD). Much more work ne...
moritz authored
192 # L<S03/Junctive operators/Junctions work through subscripting>
648ae66 [spec] fudged S03-junctions/misc.t
moritz authored
193 my $got;
194 my @foo;
82ba44c [spec] started to move junction tests (and upate POD). Much more work ne...
moritz authored
195 $got = ''; @foo = ();
196 $got ~= 'y' if try { @foo[any(1,2,3)] };
197 is($got, '', "junctions work through subscripting, 0 matches");
198
199 $got = ''; @foo = (0,1);
200 $got ~= 'y' if try { @foo[any(1,2,3)] };
8315f60 @sorear Unfudge and fix tests for junction indexes
sorear authored
201 is($got, 'y', "junctions work through subscripting, 1 match");
82ba44c [spec] started to move junction tests (and upate POD). Much more work ne...
moritz authored
202
203 $got = ''; @foo = (1,1,1);
204 $got ~= 'y' if try { @foo[any(1,2,3)] };
8315f60 @sorear Unfudge and fix tests for junction indexes
sorear authored
205 is($got, 'y', "junctions work through subscripting, 3 matches");
82ba44c [spec] started to move junction tests (and upate POD). Much more work ne...
moritz authored
206
207
208 # L<S03/Junctive operators/Junctions are specifically unordered>
209 # Compiler *can* reorder and parallelize but *may not* so don't test
210 # for all(@foo) {...};
211
212 # Not sure what is expected
213 #my %got = ('1' => 1); # Hashes are unordered too
214 #@foo = (2,3,4);
215 #for all(@foo) { %got{$_} = 1; };
216 #is( %got.keys.sort.join(','), '1,2,3,4',
217 # 'for all(...) { ...} as parallelizable');
218 }
219
220 =begin description
221
222 These are implemented but still awaiting clarification on p6l.
223
224 On Fri, 2005-02-11 at 10:46 +1100, Damian Conway wrote:
225 > Subject: Re: Fwd: Junctive puzzles.
226 >
227 > Junctions have an associated boolean predicate that's preserved across
228 > operations on the junction. Junctions also implicitly distribute across
229 > operations, and rejunctify the results.
230
231 =end description
232
eda6db1 [t/spec] move smartlinks from POD to ordinary comments
moritz authored
233 # L<S03/Junctive operators/They thread through operations>
234
82ba44c [spec] started to move junction tests (and upate POD). Much more work ne...
moritz authored
235 {
236 my @subs = (sub {3}, sub {2});
237
97213bc @sorear Fudge and defossilize S03-junctions/misc
sorear authored
238 my Mu $got;
239 my Mu $want;
82ba44c [spec] started to move junction tests (and upate POD). Much more work ne...
moritz authored
240
241 is(j(any(@subs)()), j(3|2), '.() on any() junction of subs');
242
243 $want = (3&2);
244 $got = all(@subs)();
245 is(j($got), j($want), '.() on all() junction of subs');
246
247 $want = (3^2);
248 $got = one(@subs)();
249 is(j($got), j($want), '.() on one() junction of subs');
250
251 $want = none(3,2);
252 $got = none(@subs)();
253 is(j($got), j($want), '.() on none() junction of subs');
254
255 $want = one( any(3,2), all(3,2) );
256 $got = one( any(@subs), all(@subs) )();
257 is(j($got), j($want), '.() on complex junction of subs');
258
259 # Avoid future constant folding
260 #my $rand = rand;
261 #my $zero = int($rand-$rand);
262 #my @subs = (sub {3+$zero}, sub {2+$zero});
263 }
264
265 # Check functional and operator versions produce the same structure
266 {
267 is(j((1|2)^(3&4)), j(one(any(1,2),all(3,4))),
268 '((1|2)^(3&4)) equiv to one(any(1,2),all(3,4))');
269
270 is(j((1|2)&(3&4)), j(all(any(1,2),all(3,4))),
271 '((1|2)&(3&4)) equiv to all(any(1,2),all(3,4))');
272
273 is(j((1|2)|(3&4)), j(any(any(1,2),all(3,4))),
274 '((1|2)|(3&4)) equiv to any(any(1,2),all(3,4))');
275 }
276
277 # junction in boolean context
278 ok(?(0&0) == ?(0&&0), 'boolean context');
279 ok(?(0&1) == ?(0&&1), 'boolean context');
280 ok(?(1&1) == ?(1&&1), 'boolean context');
281 ok(?(1&0) == ?(1&&0), 'boolean context');
282 ok(!(?(0&0) != ?(0&&0)), 'boolean context');
283 ok(!(?(0&1) != ?(0&&1)), 'boolean context');
284 ok(!(?(1&1) != ?(1&&1)), 'boolean context');
285 ok(!(?(1&0) != ?(1&&0)), 'boolean context');
286
287
288 {
289 my $c = 0;
290 if 1 == 1 { $c++ }
291 is $c, 1;
292 if 1 == 1|2 { $c++ }
293 is $c, 2;
294 if 1 == 1|2|3 { $c++ }
295 is $c, 3;
296
297 $c++ if 1 == 1;
298 is $c, 4;
299 $c++ if 1 == 1|2;
300 is $c, 5, 'if modifier with junction should be called once';
301
302 $c = 0;
303 $c++ if 1 == 1|2|3;
304 is $c, 1, 'if modifier with junction should be called once';
305
306 $c = 0;
307 $c++ if 1 == any(1, 2, 3);
308 is $c, 1, 'if modifier with junction should be called once';
309 }
57e7ad8 [t] move some junction tests
moritz authored
310
311 {
312 my @array = <1 2 3 4 5 6 7 8>;
e97f6d5 [t/spec] avoid autohreading through ok()
moritz authored
313 jok( all(@array) == one(@array), "all(@x) == one(@x) tests uniqueness(+ve)" );
57e7ad8 [t] move some junction tests
moritz authored
314
315 push @array, 6;
e97f6d5 [t/spec] avoid autohreading through ok()
moritz authored
316 jok( !( all(@array) == one(@array) ), "all(@x) == one(@x) tests uniqueness(-ve)" );
57e7ad8 [t] move some junction tests
moritz authored
317
318 }
1c00622 [t/spec] test for RT #60886
moritz authored
319
320 # used to be a rakudo regression (RT #60886)
f2f0e24 [t/spec] A little re-fudging that I forgot to commit earlier.
jnthn authored
321 ok Mu & Mu ~~ Mu, 'Mu & Mu ~~ Mu works';
310944a test substr on junctions
szabgab authored
322
d4cdad3 testing index() with junction
szabgab authored
323 ## See also S03-junctions/autothreading.t
310944a test substr on junctions
szabgab authored
324 {
325 is substr("abcd", 1, 2), "bc", "simple substr";
97213bc @sorear Fudge and defossilize S03-junctions/misc
sorear authored
326 my Mu $res = substr(any("abcd", "efgh"), 1, 2);
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
327 isa-ok $res, Junction;
ffa7511 [t/spec/] "Junction" -> "junction", ".eigenstates" -> "!eigenstates" (as...
Kodi authored
328 ok $res eq "bc", "substr on junctions: bc";
329 ok $res eq "fg", "substr on junctions: fg";
310944a test substr on junctions
szabgab authored
330 }
331
332 {
97213bc @sorear Fudge and defossilize S03-junctions/misc
sorear authored
333 my Mu $res = substr("abcd", 1|2, 2);
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
334 isa-ok $res, Junction;
ffa7511 [t/spec/] "Junction" -> "junction", ".eigenstates" -> "!eigenstates" (as...
Kodi authored
335 ok $res eq "bc", "substr on junctions: bc";
336 ok $res eq "cd", "substr on junctions: cd";
310944a test substr on junctions
szabgab authored
337 }
338
339 {
97213bc @sorear Fudge and defossilize S03-junctions/misc
sorear authored
340 my Mu $res = substr("abcd", 1, 1|2);
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
341 isa-ok $res, Junction;
ffa7511 [t/spec/] "Junction" -> "junction", ".eigenstates" -> "!eigenstates" (as...
Kodi authored
342 ok $res eq "bc", "substr on junctions: bc";
343 ok $res eq "b", "substr on junctions: b";
310944a test substr on junctions
szabgab authored
344 }
345
d4cdad3 testing index() with junction
szabgab authored
346 {
97213bc @sorear Fudge and defossilize S03-junctions/misc
sorear authored
347 my Mu $res = index(any("abcd", "qwebdd"), "b");
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
348 isa-ok $res, Junction;
ffa7511 [t/spec/] "Junction" -> "junction", ".eigenstates" -> "!eigenstates" (as...
Kodi authored
349 ok $res == 1, "index on junctions: 1";
350 ok $res == 3, "index on junctions: 3";
d4cdad3 testing index() with junction
szabgab authored
351 }
352
353 {
97213bc @sorear Fudge and defossilize S03-junctions/misc
sorear authored
354 my Mu $res = index("qwebdd", "b"|"w");
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
355 isa-ok $res, Junction;
ffa7511 [t/spec/] "Junction" -> "junction", ".eigenstates" -> "!eigenstates" (as...
Kodi authored
356 ok $res == 1, "index on junctions: 1";
357 ok $res == 3, "index on junctions: 3";
d4cdad3 testing index() with junction
szabgab authored
358 }
359
30c8e17 [t/spec] (perhaps incomplete) test for RT #63686
kyle authored
360 # RT #63686
361 {
362 lives_ok { try { for any(1,2) -> $x {}; } },
363 'for loop over junction in try block';
26751c8 naive implementation of comparing two junctions
szabgab authored
364
30c8e17 [t/spec] (perhaps incomplete) test for RT #63686
kyle authored
365 sub rt63686 {
8dc7d4b [t/spec] mark various tests that intentionally declare things that are n...
lwall authored
366 for any(1,2) -> $x {}; #OK not used
30c8e17 [t/spec] (perhaps incomplete) test for RT #63686
kyle authored
367 return 'happiness';
368 }
369 is rt63686(), 'happiness', 'for loop over junction in sub';
370 }
7f29bc5 [t/spec] Add vim: lines everywhere.
kyle authored
371
b49fcef @coke use RT #XXXX where possible
coke authored
372 # RT #67866: [BUG] [LHF] Error with stringifying .WHAT on any junctions
8d4ec02 [t/spec] remove some junction tests that relied on internal methods; fud...
moritz authored
373 #?rakudo skip 'lower case junction'
97213bc @sorear Fudge and defossilize S03-junctions/misc
sorear authored
374 #?niecza skip 'Impossible test: === takes Any'
3c2bc42 * add tests for RT#67866
smash authored
375 {
97213bc @sorear Fudge and defossilize S03-junctions/misc
sorear authored
376 ok((WHAT any()) === Junction, "test WHAT on empty any junction");
377 ok(any().WHAT === Junction, "test WHAT on empty any junction");
378 ok((WHAT any(1,2)) === Junction, "test WHAT on any junction");
379 ok(any(1,2).WHAT === Junction, "test WHAT on any junction");
3c2bc42 * add tests for RT#67866
smash authored
380 }
4f9deaa RT#75626 tests - Implement Any.all (and .any, .one, .none) in Rakudo
mmcleric authored
381
382 # Any list has junction methods
383 {
384 jok(5 < (6,7,8).all, '.all method builds "all" junction');
385 jok(!(7 < (6,7,8).all), '.all method builds "all" junction');
386 jok(7 == (6,7,8).one, '.one method builds "one" junction');
387 jok(9 == (6,7,8).none, '.none method builds "none" junction');
388
389 my @x = (6,7,8);
390 jok(5 < @x.all, '.all method works on array objects');
391 }
09302fd [t/spec] tests for RT #63126 Junctions in array and hash indices dont wo...
bbkr authored
392
393 # RT #63126
33955a8 @coke rakudo unfudge
coke authored
394 #?rakudo todo 'nom regression'
0836cea @coke nom fudging
coke authored
395 #?DOES 2
09302fd [t/spec] tests for RT #63126 Junctions in array and hash indices dont wo...
bbkr authored
396 {
397 my @a = "foo", "foot";
398 ok @a[all(0,1)] ~~ /^foo/,
399 'junction can be used to index Array';
400
401 my %h = (
402 "0" => "foo",
403 "1" => "foot"
404 );
405 ok %h{all(0,1)} ~~ /^foo/,
406 'junction can be used to index Hash';
407 }
e05e9cc @coke niecza fudging
coke authored
408
a4ed986 @lumimies Test for some Junction stringifications
lumimies authored
409 # stringy tests
6c7def2 @coke niecza (auto)unfudge
coke authored
410 #?niecza todo '#82'
a4ed986 @lumimies Test for some Junction stringifications
lumimies authored
411 {
412 my class Foo {
413 multi method gist(Foo:D:) { "gisted"; }
414 multi method perl(Foo:D:) { "perled"; }
415 multi method Str(Foo:D:) { "Stred"; }
416 }
417 is any(Foo.new).perl, 'any(perled)', 'any(Foo.new).perl';
418 is any(Foo.new).gist, 'any(gisted)', 'any(Foo.new).gist';
419 }
09302fd [t/spec] tests for RT #63126 Junctions in array and hash indices dont wo...
bbkr authored
420
31654a6 @moritz RT #109188, junctions with the List type object
moritz authored
421 # RT #109188
422 ok { a => 1} ~~ List|Hash, 'Can construct junction with List type object';
423
b19c74d @moritz RT #112392: Junction.Str should return a, well, Str
moritz authored
424 # RT #112392
425 ok (1|2).Str ~~ Str, 'Junction.Str returns a Str, not a Junction';
426
a7e1209 @coke Add a test for RT #101124
coke authored
427 # RT #101124
428 ok (0|1 == 0&1), 'test junction evaluation order';
429 ok (0&1 == 0|1), 'test junction evaluation order';
430
e76dd4c @moritz s/done_testing/done/ as per recent S24 changes
moritz authored
431 done();
3c2bc42 * add tests for RT#67866
smash authored
432
7f29bc5 [t/spec] Add vim: lines everywhere.
kyle authored
433 # vim: ft=perl6
Something went wrong with that request. Please try again.