Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 78 lines (71 sloc) 3.319 kB
e67eb0c [t/spec] split S03-operators/smartmatch.t into S03-smartmatch/*.t
kyle authored
1 use v6;
2 use Test;
5caf057 @skids Fix plan.
skids authored
3 plan 38;
e67eb0c [t/spec] split S03-operators/smartmatch.t into S03-smartmatch/*.t
kyle authored
4
5 #L<S03/Smart matching/arrays are comparable>
74e7601 [t/spec] a tiny unfudge for rakudo
moritz authored
6 {
e67eb0c [t/spec] split S03-operators/smartmatch.t into S03-smartmatch/*.t
kyle authored
7 ok((("blah", "blah") ~~ ("blah", "blah")), "qw/blah blah/ .eq");
8 ok(!((1, 2) ~~ (1, 1)), "1 2 !~~ 1 1");
9 ok(!((1, 2, 3) ~~ (1, 2)), "1 2 3 !~~ 1 2");
10 ok(!((1, 2) ~~ (1, 2, 3)), "1 2 !~~ 1 2 3");
ae8ff8d [t/spec] Bring some tests in line with the spec.
jnthn authored
11 ok(!([] ~~ [1]), "array smartmatch boundary conditions");
12 ok(!([1] ~~ []), "array smartmatch boundary conditions");
13 ok(([] ~~ []), "array smartmatch boundary conditions");
14 ok(([1] ~~ [1]), "array smartmatch boundary conditions");
4bdf17e @coke Convert niecza faux-todo to real todo.
coke authored
15 #?niecza todo
e67eb0c [t/spec] split S03-operators/smartmatch.t into S03-smartmatch/*.t
kyle authored
16 ok((1,2,3,4) ~~ (1,*), 'array smartmatch dwims * at end');
4bdf17e @coke Convert niecza faux-todo to real todo.
coke authored
17 #?niecza todo
e67eb0c [t/spec] split S03-operators/smartmatch.t into S03-smartmatch/*.t
kyle authored
18 ok((1,2,3,4) ~~ (1,*,*), 'array smartmatch dwims * at end (many *s)');
4bdf17e @coke Convert niecza faux-todo to real todo.
coke authored
19 #?niecza todo
e67eb0c [t/spec] split S03-operators/smartmatch.t into S03-smartmatch/*.t
kyle authored
20 ok((1,2,3,4) ~~ (*,4), 'array smartmatch dwims * at start');
4bdf17e @coke Convert niecza faux-todo to real todo.
coke authored
21 #?niecza todo
e67eb0c [t/spec] split S03-operators/smartmatch.t into S03-smartmatch/*.t
kyle authored
22 ok((1,2,3,4) ~~ (*,*,4), 'array smartmatch dwims * at start (many *s)');
4bdf17e @coke Convert niecza faux-todo to real todo.
coke authored
23 #?niecza todo
e67eb0c [t/spec] split S03-operators/smartmatch.t into S03-smartmatch/*.t
kyle authored
24 ok((1,2,3,4) ~~ (1,*,3,4), 'array smartmatch dwims * 1 elem');
4bdf17e @coke Convert niecza faux-todo to real todo.
coke authored
25 #?niecza todo
e67eb0c [t/spec] split S03-operators/smartmatch.t into S03-smartmatch/*.t
kyle authored
26 ok((1,2,3,4) ~~ (1,*,*,3,4), 'array smartmatch dwims * 1 elem (many *s)');
4bdf17e @coke Convert niecza faux-todo to real todo.
coke authored
27 #?niecza todo
e67eb0c [t/spec] split S03-operators/smartmatch.t into S03-smartmatch/*.t
kyle authored
28 ok((1,2,3,4) ~~ (1,*,4), 'array smartmatch dwims * many elems');
4bdf17e @coke Convert niecza faux-todo to real todo.
coke authored
29 #?niecza todo
e67eb0c [t/spec] split S03-operators/smartmatch.t into S03-smartmatch/*.t
kyle authored
30 ok((1,2,3,4) ~~ (1,*,*,4), 'array smartmatch dwims * many elems (many *s)');
4bdf17e @coke Convert niecza faux-todo to real todo.
coke authored
31 #?niecza todo
e67eb0c [t/spec] split S03-operators/smartmatch.t into S03-smartmatch/*.t
kyle authored
32 ok((1,2,3,4) ~~ (*,3,*), 'array smartmatch dwims * at start and end');
4bdf17e @coke Convert niecza faux-todo to real todo.
coke authored
33 #?niecza todo
e67eb0c [t/spec] split S03-operators/smartmatch.t into S03-smartmatch/*.t
kyle authored
34 ok((1,2,3,4) ~~ (*,*,3,*,*), 'array smartmatch dwims * at start and end (many *s)');
4bdf17e @coke Convert niecza faux-todo to real todo.
coke authored
35 #?niecza todo
e67eb0c [t/spec] split S03-operators/smartmatch.t into S03-smartmatch/*.t
kyle authored
36 ok((1,2,3,4) ~~ (*,1,2,3,4), 'array smartmatch dwims * can match nothing at start');
4bdf17e @coke Convert niecza faux-todo to real todo.
coke authored
37 #?niecza todo
e67eb0c [t/spec] split S03-operators/smartmatch.t into S03-smartmatch/*.t
kyle authored
38 ok((1,2,3,4) ~~ (*,*,1,2,3,4), 'array smartmatch dwims * can match nothing at start (many *s)');
4bdf17e @coke Convert niecza faux-todo to real todo.
coke authored
39 #?niecza todo
e67eb0c [t/spec] split S03-operators/smartmatch.t into S03-smartmatch/*.t
kyle authored
40 ok((1,2,3,4) ~~ (1,2,*,3,4), 'array smartmatch dwims * can match nothing in middle');
4bdf17e @coke Convert niecza faux-todo to real todo.
coke authored
41 #?niecza todo
e67eb0c [t/spec] split S03-operators/smartmatch.t into S03-smartmatch/*.t
kyle authored
42 ok((1,2,3,4) ~~ (1,2,*,*,3,4), 'array smartmatch dwims * can match nothing in middle (many *s)');
4bdf17e @coke Convert niecza faux-todo to real todo.
coke authored
43 #?niecza todo
e67eb0c [t/spec] split S03-operators/smartmatch.t into S03-smartmatch/*.t
kyle authored
44 ok((1,2,3,4) ~~ (1,2,3,4,*), 'array smartmatch dwims * can match nothing at end');
4bdf17e @coke Convert niecza faux-todo to real todo.
coke authored
45 #?niecza todo
e67eb0c [t/spec] split S03-operators/smartmatch.t into S03-smartmatch/*.t
kyle authored
46 ok((1,2,3,4) ~~ (1,2,3,4,*,*), 'array smartmatch dwims * can match nothing at end (many *s)');
47 ok(!((1,2,3,4) ~~ (1,*,3)), '* dwimming does not cause craziness');
48 ok(!((1,2,3,4) ~~ (*,5)), '* dwimming does not cause craziness');
49 ok(!((1,2,3,4) ~~ (1,3,*)), '* dwimming does not cause craziness');
50
51 # now try it with arrays as well
52 my @a = 1, 2, 3;
53 my @b = 1, 2, 4;
54 my @m = (*, 2, *); # m as "magic" ;-)
55
56 ok (@a ~~ @a), 'Basic smartmatching on arrays (positive)';
57 ok (@a !~~ @b), 'Basic smartmatching on arrays (negative)';
58 ok (@b !~~ @a), 'Basic smartmatching on arrays (negative)';
4bdf17e @coke Convert niecza faux-todo to real todo.
coke authored
59 #?niecza todo
e67eb0c [t/spec] split S03-operators/smartmatch.t into S03-smartmatch/*.t
kyle authored
60 ok (@a ~~ @m), 'Whatever dwimminess in arrays';
61 ok (@a ~~ (1, 2, 3)), 'smartmatch Array ~~ List';
62 ok ((1, 2, 3) ~~ @a), 'smartmatch List ~~ Array';
4bdf17e @coke Convert niecza faux-todo to real todo.
coke authored
63 #?niecza todo
e67eb0c [t/spec] split S03-operators/smartmatch.t into S03-smartmatch/*.t
kyle authored
64 ok ((1, 2, 3) ~~ @m), 'smartmatch List ~~ Array with dwim';
65
66 ok (1 ~~ *,1,*), 'smartmatch with Array RHS co-erces LHS to list';
687df77 @TimToady Revert "benign prep for ~~ going chained -> structural"
TimToady authored
67 ok (1..10 ~~ *,5,*), 'smartmatch with Array RHS co-erces LHS to list';
e67eb0c [t/spec] split S03-operators/smartmatch.t into S03-smartmatch/*.t
kyle authored
68 }
69
db772bd @skids Add (fudged) tests for RT#123144
skids authored
70 # RT#123144
71 #?rakudo todo 'RT#123144 comparison dies on forced numeric context'
72 {
73 eval-lives-ok '["a","b","c"] ~~ [*, "b", "c"]', "Str and Whatever (1)";
74 eval-lives-ok '[1,2,3] ~~ [*, "b", "c"]', "Str and Whatever (2)";
75 }
76
e67eb0c [t/spec] split S03-operators/smartmatch.t into S03-smartmatch/*.t
kyle authored
77 # vim: ft=perl6
Something went wrong with that request. Please try again.