Skip to content
Newer
Older
100644 225 lines (192 sloc) 9.59 KB
9a58617 [gsoc_spectest] reorganization and a few more tests for ===, eqv, and…
Auzon authored Jun 30, 2008
1 use v6;
2
3 use Test;
4
7509d77 [t/spec] tests for RT #68788 segmentation fault on the "say 1..{$_}"
bbkr authored Jun 30, 2010
5 plan 116;
7f76022 [t/spec] forbid lists and ranges as Range end points (as per r28171)
moritz authored Sep 13, 2009
6
7
8 # L<S03/Nonchaining binary precedence/Range object constructor>
9a58617 [gsoc_spectest] reorganization and a few more tests for ===, eqv, and…
Auzon authored Jun 30, 2008
9
10 # 3..2 must *not* produce "3 2". Use reverse to get a reversed range. -lwall
11
12 is ~(3..6), "3 4 5 6", "(..) works on numbers (1)";
13 is ~(3..3), "3", "(..) works on numbers (2)";
a971e66 [pugs_s02,s03] moved the auto-reversing range tests to the S03-operat…
s1n authored Jul 25, 2008
14 is ~(3..2), "", "(..) works on auto-rev numbers (3)";
9a58617 [gsoc_spectest] reorganization and a few more tests for ===, eqv, and…
Auzon authored Jun 30, 2008
15 is ~(8..11), "8 9 10 11", "(..) works on carried numbers (3)";
16
17 is ~("a".."c"), "a b c", "(..) works on chars (1)";
18 is ~("a".."a"), "a", "(..) works on chars (2)";
19 is ~("b".."a"), "", "(..) works on chars (3)";
b5ee073 [t/spec] Unfudge series / Range tests Rakudo now passes, and add a fe…
colomon authored Jun 17, 2010
20 is ~("a".."z"), "a b c d e f g h i j k l m n o p q r s t u v w x y z", "(..) works on char range ending in z";
21 is ~("A".."Z"), "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z", "(..) works on char range ending in Z";
2bb1c63 [t/spec] Refudge to work with list branch.
colomon authored Jun 15, 2010
22 is ~("Y".."AB"), "", "(..) works on carried chars (3)";
9a58617 [gsoc_spectest] reorganization and a few more tests for ===, eqv, and…
Auzon authored Jun 30, 2008
23
2bb1c63 [t/spec] Refudge to work with list branch.
colomon authored Jun 15, 2010
24 #?rakudo 4 skip 'Spec under design here'
a971e66 [pugs_s02,s03] moved the auto-reversing range tests to the S03-operat…
s1n authored Jul 25, 2008
25 is ~('Y'..'z'), 'Y Z', '(..) works on uppercase letter .. lowercase letter (1)';
26 is ~('z'..'Y'), '', '(..) works on auto-rev uppercase letter .. lowercase letter (2)';
27 is ~('Y'..'_'), 'Y Z', '(..) works on letter .. non-letter (1)';
28 is ~('_'..'Y'), '', '(..) works on auto-rev letter .. non-letter (2)';
9a58617 [gsoc_spectest] reorganization and a few more tests for ===, eqv, and…
Auzon authored Jun 30, 2008
29
3da5e46 [t/spec] test for RT #76226, all-whitespace range
moritz authored Jun 28, 2010
30 is ~(' '..' '), ' ', 'all-whitespace range works';
31
9a58617 [gsoc_spectest] reorganization and a few more tests for ===, eqv, and…
Auzon authored Jun 30, 2008
32 is ~(3..9-3), "3 4 5 6", "(..) has correct precedence (1)";
a971e66 [pugs_s02,s03] moved the auto-reversing range tests to the S03-operat…
s1n authored Jul 25, 2008
33 is ~(5..9-5), "", "(..) has correct precedence (2)";
34 is ~(2+1..6), "3 4 5 6", "(..) has correct precedence (3)";
35 is ~(2+5..6), "", "(..) has correct precedence (4)";
9a58617 [gsoc_spectest] reorganization and a few more tests for ===, eqv, and…
Auzon authored Jun 30, 2008
36
37 # Test the three exclusive range operators:
832f178 [t/spec] fix more smartlinks; down to 33 broken links
moritz authored Mar 18, 2010
38 # L<S03/Range and RangeIter semantics/range operator has variants>
a971e66 [pugs_s02,s03] moved the auto-reversing range tests to the S03-operat…
s1n authored Jul 25, 2008
39 is [1^..9], [2..9], "bottom-exclusive range (^..) works (1)";
40 is [2^..2], [], "bottom-exclusive range (^..) works (2)";
41 is [3^..2], [], "bottom-exclusive auto-rev range (^..) works (3)";
42 is [1 ..^9], [1..8], "top-exclusive range (..^) works (1)";
43 is [2 ..^2], [], "top-exclusive range (..^) works (2)";
44 is [3 ..^2], [], "top-exclusive auto-rev range (..^) works (3)";
45 is [1^..^9], [2..8], "double-exclusive range (^..^) works (1)";
46 is [9^..^1], [], "double-exclusive auto-rev range (^..^) works (2)";
47 is [1^..^2], [], "double-exclusive range (^..^) can produce null range (1)";
9a58617 [gsoc_spectest] reorganization and a few more tests for ===, eqv, and…
Auzon authored Jun 30, 2008
48
49 # tests of (x ^..^ x) here and below ensure that our implementation
50 # of double-exclusive range does not blindly remove an element
51 # from the head and tail of a list
52 is [1^..^1], [], "double-exclusive range (x ^..^ x) where x is an int";
53
54 is ["a"^.."z"], ["b".."z"], "bottom-exclusive string range (^..) works";
a971e66 [pugs_s02,s03] moved the auto-reversing range tests to the S03-operat…
s1n authored Jul 25, 2008
55 is ["z"^.."a"], [], "bottom-exclusive string auto-rev range (^..) works";
9a58617 [gsoc_spectest] reorganization and a few more tests for ===, eqv, and…
Auzon authored Jun 30, 2008
56 is ["a"..^"z"], ["a".."y"], "top-exclusive string range (..^) works";
a971e66 [pugs_s02,s03] moved the auto-reversing range tests to the S03-operat…
s1n authored Jul 25, 2008
57 is ["z"..^"a"], [], "top-exclusive string auto-rev range (..^) works";
9a58617 [gsoc_spectest] reorganization and a few more tests for ===, eqv, and…
Auzon authored Jun 30, 2008
58 is ["a"^..^"z"], ["b".."y"], "double-exclusive string range (^..^) works";
a971e66 [pugs_s02,s03] moved the auto-reversing range tests to the S03-operat…
s1n authored Jul 25, 2008
59 is ["z"^..^"a"], [], "double-exclusive string auto-rev range (^..^) works";
9a58617 [gsoc_spectest] reorganization and a few more tests for ===, eqv, and…
Auzon authored Jun 30, 2008
60 is ['a'^..^'b'], [], "double-exclusive string range (^..^) can produce null range";
a971e66 [pugs_s02,s03] moved the auto-reversing range tests to the S03-operat…
s1n authored Jul 25, 2008
61 is ['b'^..^'a'], [], "double-exclusive string auto-rev range (^..^) can produce null range";
9a58617 [gsoc_spectest] reorganization and a few more tests for ===, eqv, and…
Auzon authored Jun 30, 2008
62 is ['a' ^..^ 'a'], [], "double-exclusive range (x ^..^ x) where x is a char";
63
ba8e84a [t/spec] Change more Pugs todo flags to fudge commands
kyle authored Jun 19, 2009
64 #?pugs todo 'bug'
65 is 1.5 ~~ 1^..^2, Bool::True, "lazy evaluation of the range operator";
9a58617 [gsoc_spectest] reorganization and a few more tests for ===, eqv, and…
Auzon authored Jun 30, 2008
66
67 # Test the unary ^ operator
68 is ~(^5), "0 1 2 3 4", "unary ^num produces the range 0..^num";
a971e66 [pugs_s02,s03] moved the auto-reversing range tests to the S03-operat…
s1n authored Jul 25, 2008
69 is [^1], [0], "unary ^ on the boundary ^1 works";
70 is [^0], [], "unary ^0 produces null range";
71 is [^-1], [], "unary ^-1 produces null range";
72 is [^0.1], [0], "unary ^0.1 produces the range 0..^x where 0 < x < 1";
73 is [^'a'], [], "unary ^'a' produces null range";
64b5bba [t/spec] Refudge a tad, add a couple of tests to make sure prefix:<^>…
colomon authored May 9, 2010
74 is ~(^"5"), "0 1 2 3 4", 'unary ^"num" produces the range 0..^num';
75
76 {
77 my @a = 3, 5, 3;
78 is (^@a).perl, (0..^3).perl, 'unary ^@a produces 0..^+@a';
79 }
9a58617 [gsoc_spectest] reorganization and a few more tests for ===, eqv, and…
Auzon authored Jun 30, 2008
80
b5ee073 [t/spec] Unfudge series / Range tests Rakudo now passes, and add a fe…
colomon authored Jun 17, 2010
81 # test iterating on infinite ranges
82 is (1..*).[^5].join('|'), '1|2|3|4|5', '1..*';
83 is ('a'..*).[^5].join('|'), 'a|b|c|d|e', '"a"..*';
84
e8dc6d6 [t/spec] regression tests for RT #60898 (ranges + infix:<Z>)
moritz authored Nov 30, 2008
85 # test that the zip operator works with ranges
86 is (1..5 Z <a b c>).join('|'), '1|a|2|b|3|c', 'Ranges and infix:<Z>';
87 is (1..2 Z <a b c>).join('|'), '1|a|2|b', 'Ranges and infix:<Z>';
88 is (<c b a> Z 1..5).join('|'), 'c|1|b|2|a|3', 'Ranges and infix:<Z>';
89
90 # two ranges
49d046f .join now defaults to ''
lwall authored Apr 8, 2009
91 is (1..6 Z 'a' .. 'c').join, '1a2b3c', 'Ranges and infix:<Z>';
e8dc6d6 [t/spec] regression tests for RT #60898 (ranges + infix:<Z>)
moritz authored Nov 30, 2008
92
ba2d31c [spec] fudged and corrected range.t
moritz authored Jun 30, 2008
93 {
94 # Test with floats
95 # 2006-12-05:
96 # 16:16 <TimToady> ~(1.9 ^..^ 4.9) should produce 2.9, 3.9
97 # 16:17 <pmichaud> and ~(1.9 ^..^ 4.5) would produce the same?
98 # 16:17 <TimToady> yes
99 is ~(1.1 .. 4) , "1.1 2.1 3.1", "range with float .min";
100 is ~(1.9 .. 4) , "1.9 2.9 3.9", "range with float .min";
101 is ~(1.1 ^.. 4), "2.1 3.1" , "bottom exclusive range of float";
102 is ~(1.9 ^.. 4), "2.9 3.9" , "bottom exclusive range of float";
103
104 is ~(1 .. 4.1) , "1 2 3 4", "range with float .max";
105 is ~(1 .. 4.9) , "1 2 3 4", "range with float .max";
106 is ~(1 ..^ 4.1), "1 2 3 4", "top exclusive range of float";
107 is ~(1 ..^ 4.9), "1 2 3 4", "top exclusive range of float";
108
109 is ~(1.1 .. 4.1), "1.1 2.1 3.1 4.1", "range with float .min/.max";
110 is ~(1.9 .. 4.1), "1.9 2.9 3.9" , "range with float .min/.max";
111 is ~(1.1 .. 4.9), "1.1 2.1 3.1 4.1", "range with float .min/.max";
112 is ~(1.9 .. 4.9), "1.9 2.9 3.9 4.9", "range with float .min/.max";
113
114 is ~(1.1 ^..^ 4.1), "2.1 3.1" , "both exclusive float range";
115 is ~(1.9 ^..^ 4.1), "2.9 3.9" , "both exclusive float range";
116 is ~(1.1 ^..^ 4.9), "2.1 3.1 4.1", "both exclusive float range";
117 is ~(1.9 ^..^ 4.9), "2.9 3.9" , "both exclusive float range";
118 is [1.1 ^..^ 1.1], [], "double-exclusive range (x ^..^ x) where x is a float";
119 }
9a58617 [gsoc_spectest] reorganization and a few more tests for ===, eqv, and…
Auzon authored Jun 30, 2008
120
121 # Test that the operands are forced to scalar context
748e055 S03-operators/range.t: Add note about use of @array as arguments to i…
pmichaud authored Jun 30, 2008
122 ## From pmichaud 2006-06-30: These tests may be incorrect.
123 ## C<@one> in ## item context returns an Array, not a number
124 ## -- use C< +@one > to get the number of elements. So, we
125 ## need to either declare that there's a version of infix:<..>
126 ## that coerces its arguments to numeric context, or we can
127 ## remove these tests from the suite.
ffc88f9 [t/spec] add RT #58018 marker to tests in range.t
moritz authored Jul 23, 2010
128 # RT #58018
ba2d31c [spec] fudged and corrected range.t
moritz authored Jun 30, 2008
129 #?rakudo skip 'MMD function __cmp not found for types (101, 95)'
9a58617 [gsoc_spectest] reorganization and a few more tests for ===, eqv, and…
Auzon authored Jun 30, 2008
130 {
131 my @three = (1, 1, 1);
f07dd23 [t/spec] a test for Range.map
moritz authored Dec 19, 2008
132 my @one = 1;
9a58617 [gsoc_spectest] reorganization and a few more tests for ===, eqv, and…
Auzon authored Jun 30, 2008
133
134 is ~(@one .. 3) , "1 2 3", "lower inclusive limit is in scalar context";
135 is ~(@one ^.. 3) , "2 3" , "lower exclusive limit is in scalar context";
a971e66 [pugs_s02,s03] moved the auto-reversing range tests to the S03-operat…
s1n authored Jul 25, 2008
136 is ~(3 ^.. @one) , "" , "lower exclusive limit is in scalar context";
9a58617 [gsoc_spectest] reorganization and a few more tests for ===, eqv, and…
Auzon authored Jun 30, 2008
137 is ~(1 .. @three) , "1 2 3", "upper inclusive limit is in scalar context";
a971e66 [pugs_s02,s03] moved the auto-reversing range tests to the S03-operat…
s1n authored Jul 25, 2008
138 is ~(4 .. @three) , "" , "upper inclusive limit is in scalar context";
9a58617 [gsoc_spectest] reorganization and a few more tests for ===, eqv, and…
Auzon authored Jun 30, 2008
139 is ~(1 ..^ @three) , "1 2" , "upper exclusive limit is in scalar context";
a971e66 [pugs_s02,s03] moved the auto-reversing range tests to the S03-operat…
s1n authored Jul 25, 2008
140 is ~(4 ..^ @three) , "" , "upper exclusive limit is in scalar context";
9a58617 [gsoc_spectest] reorganization and a few more tests for ===, eqv, and…
Auzon authored Jun 30, 2008
141 is ~(@one .. @three), "1 2 3", "both inclusive limits are in scalar context";
142 is ~(@three .. @one), "" , "null range produced with lists forced to scalar context";
a971e66 [pugs_s02,s03] moved the auto-reversing range tests to the S03-operat…
s1n authored Jul 25, 2008
143 is ~(@one ^..^ @three), "2" , "both exclusive limits are in scalar context";
144 is ~(@three ^..^ @one), "" , "both exclusive limits are in scalar context";
9a58617 [gsoc_spectest] reorganization and a few more tests for ===, eqv, and…
Auzon authored Jun 30, 2008
145 }
146
3f4b761 [t/spec] test for .grep on Range, and unfudge Range.map test
moritz authored Dec 20, 2008
147 # test that .map and .grep work on ranges
f07dd23 [t/spec] a test for Range.map
moritz authored Dec 19, 2008
148 {
3f4b761 [t/spec] test for .grep on Range, and unfudge Range.map test
moritz authored Dec 20, 2008
149 is (0..3).map({$_ * 2}).join('|'), '0|2|4|6', '.map works on ranges';
150 is (0..3).grep({$_ == 1|3}).join('|'), '1|3', '.grep works on ranges';
b0e0a3a [t/spec] test that .first and .reduce work on ranges
moritz authored Dec 22, 2008
151 is (1..3).first({ $_ % 2 == 0}), 2, '.first works on ranges';
152 is (1..3).reduce({ $^a + $^b}), 6, '.reduce works on ranges';
f07dd23 [t/spec] a test for Range.map
moritz authored Dec 19, 2008
153 }
154
d4459dc Add another range test case around the match operator, and an equival…
colomon authored Jul 26, 2009
155 # test that range operands are handled in string context if strings
156 {
157 my $range;
158 my $start = "100.B";
159 my $end = "102.B";
160 lives_ok { $range = $start..$end },
161 'can make range from numeric string vars';
0a84065 [t/spec] Fudge for ng.
colomon authored Feb 10, 2010
162 is $range.min, $start, 'range starts at start';
163 is $range.min.WHAT, "Str()", 'range start is a string';
164 is $range.max, $end, 'range ends at end';
165 is $range.max.WHAT, "Str()", 'range end is a string';
d4459dc Add another range test case around the match operator, and an equival…
colomon authored Jul 26, 2009
166 lives_ok { "$range" }, 'can stringify range';
0a84065 [t/spec] Fudge for ng.
colomon authored Feb 10, 2010
167 is ~$range, "100.B 101.B 102.B", 'range is correct';
d4459dc Add another range test case around the match operator, and an equival…
colomon authored Jul 26, 2009
168 }
0a84065 [t/spec] Fudge for ng.
colomon authored Feb 10, 2010
169
b390af6 Tag test with RT number.
colomon authored Jul 25, 2009
170 # RT #67882
82915ee [t/spec] Test bug from colomon++
kyle authored Jul 25, 2009
171 {
172 my $range;
173 lives_ok { '1 3' ~~ /(\d+) \s (\d+)/; $range = $0..$1 },
174 'can make range from match vars';
0a84065 [t/spec] Fudge for ng.
colomon authored Feb 10, 2010
175 is $range.min, 1, 'range starts at one';
176 is $range.max, 3, 'range ends at three';
82915ee [t/spec] Test bug from colomon++
kyle authored Jul 25, 2009
177 lives_ok { "$range" }, 'can stringify range';
0a84065 [t/spec] Fudge for ng.
colomon authored Feb 10, 2010
178 is ~$range, "1 2 3", 'range is correct';
82915ee [t/spec] Test bug from colomon++
kyle authored Jul 25, 2009
179 }
0877354 [t/spec] unfudge tests for RT #67882, and add a few more (because I d…
moritz authored May 30, 2010
180 # and another set, just for the lulz
181 # RT #67882
182 {
183 ok '1 3' ~~ /(\d) . (\d)/, 'regex sanity';
184 isa_ok $0..$1, Range, '$0..$1 constructs a Range';
185 is ($0..$1).join('|'), '1|2|3', 'range from $0..$1';
186 }
82915ee [t/spec] Test bug from colomon++
kyle authored Jul 25, 2009
187 {
188 my $range;
189 lives_ok { '1 3' ~~ /(\d+) \s (\d+)/; $range = +$0..+$1 },
190 'can make range from match vars with numeric context forced';
0a84065 [t/spec] Fudge for ng.
colomon authored Feb 10, 2010
191 is $range.min, 1, 'range starts at one';
192 is $range.max, 3, 'range ends at three';
82915ee [t/spec] Test bug from colomon++
kyle authored Jul 25, 2009
193 lives_ok { "$range" }, 'can stringify range';
0a84065 [t/spec] Fudge for ng.
colomon authored Feb 10, 2010
194 is ~$range, "1 2 3", 'range is correct';
d4459dc Add another range test case around the match operator, and an equival…
colomon authored Jul 26, 2009
195 }
196 {
197 my $range;
198 lives_ok { '1 3' ~~ /(\d+) \s (\d+)/; $range = ~$0..~$1 },
199 'can make range from match vars with string context forced';
0a84065 [t/spec] Fudge for ng.
colomon authored Feb 10, 2010
200 is $range.min, 1, 'range starts at one';
201 is $range.min.WHAT, "Str()", 'range start is a string';
202 is $range.max, 3, 'range ends at three';
203 is $range.max.WHAT, "Str()", 'range end is a string';
d4459dc Add another range test case around the match operator, and an equival…
colomon authored Jul 26, 2009
204 lives_ok { "$range" }, 'can stringify range';
0a84065 [t/spec] Fudge for ng.
colomon authored Feb 10, 2010
205 is ~$range, "1 2 3", 'range is correct';
82915ee [t/spec] Test bug from colomon++
kyle authored Jul 25, 2009
206 }
207
7f76022 [t/spec] forbid lists and ranges as Range end points (as per r28171)
moritz authored Sep 13, 2009
208 # L<S03/Nonchaining binary precedence/it is illegal to use a Range or a
209 # List as implicitly numeric:>
210
211 #?rakudo todo 'forbid Ranges and Lists as Range endpoints'
212 {
213 ok !defined(try { 0 .. ^10 }), '0 .. ^10 is illegal';
214 ok !defined(try { 0 .. (0, 1, 2) }), '0 .. List is illegal';
215 }
216
7509d77 [t/spec] tests for RT #68788 segmentation fault on the "say 1..{$_}"
bbkr authored Jun 30, 2010
217 # RT #68788
218 {
219 $_ = Any; # unsetting $_ to reproduce bug literally
220 lives_ok {(1..$_)}, '(1..$_) lives';
221 isa_ok (1..$_), Range, '(..) works on Int .. Any';
222 }
0877354 [t/spec] unfudge tests for RT #67882, and add a few more (because I d…
moritz authored May 30, 2010
223
0a84065 [t/spec] Fudge for ng.
colomon authored Feb 10, 2010
224 # # vim: ft=perl6
Something went wrong with that request. Please try again.