Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 123 lines (102 sloc) 6.239 kb
9a58617 [gsoc_spectest] reorganization and a few more tests for ===, eqv, and…
Auzon authored
1 use v6;
2
3 use Test;
4
a971e66 [pugs_s02,s03] moved the auto-reversing range tests to the S03-operat…
s1n authored
5 plan 72;
9a58617 [gsoc_spectest] reorganization and a few more tests for ===, eqv, and…
Auzon authored
6
7 # 3..2 must *not* produce "3 2". Use reverse to get a reversed range. -lwall
8
9 is ~(3..6), "3 4 5 6", "(..) works on numbers (1)";
10 is ~(3..3), "3", "(..) works on numbers (2)";
a971e66 [pugs_s02,s03] moved the auto-reversing range tests to the S03-operat…
s1n authored
11 is ~(3..2), "", "(..) works on auto-rev numbers (3)";
9a58617 [gsoc_spectest] reorganization and a few more tests for ===, eqv, and…
Auzon authored
12 is ~(8..11), "8 9 10 11", "(..) works on carried numbers (3)";
13
14 is ~("a".."c"), "a b c", "(..) works on chars (1)";
15 is ~("a".."a"), "a", "(..) works on chars (2)";
16 is ~("b".."a"), "", "(..) works on chars (3)";
17 is ~("Y".."AB"), "Y Z AA AB", "(..) works on carried chars (3)";
a971e66 [pugs_s02,s03] moved the auto-reversing range tests to the S03-operat…
s1n authored
18 is ~("AB".."Y"), "", "(..) works on auto-rev carried chars (4)";
9a58617 [gsoc_spectest] reorganization and a few more tests for ===, eqv, and…
Auzon authored
19
a971e66 [pugs_s02,s03] moved the auto-reversing range tests to the S03-operat…
s1n authored
20 is ~('Y'..'z'), 'Y Z', '(..) works on uppercase letter .. lowercase letter (1)';
21 is ~('z'..'Y'), '', '(..) works on auto-rev uppercase letter .. lowercase letter (2)';
22 is ~('Y'..'_'), 'Y Z', '(..) works on letter .. non-letter (1)';
23 is ~('_'..'Y'), '', '(..) works on auto-rev letter .. non-letter (2)';
9a58617 [gsoc_spectest] reorganization and a few more tests for ===, eqv, and…
Auzon authored
24
4c815b6 S03-operators/range.t: correct a syntax error, remove some #?rakudo …
pmichaud authored
25 isnt ~(0..^10), ~(0.. ^10), '(0..^10) is not the same as (0.. ^10)';
9a58617 [gsoc_spectest] reorganization and a few more tests for ===, eqv, and…
Auzon authored
26
27 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
28 is ~(5..9-5), "", "(..) has correct precedence (2)";
29 is ~(2+1..6), "3 4 5 6", "(..) has correct precedence (3)";
30 is ~(2+5..6), "", "(..) has correct precedence (4)";
9a58617 [gsoc_spectest] reorganization and a few more tests for ===, eqv, and…
Auzon authored
31
32 # Test the three exclusive range operators:
33 # L<S03/Range semantics/range operator has variants>
a971e66 [pugs_s02,s03] moved the auto-reversing range tests to the S03-operat…
s1n authored
34 is [1^..9], [2..9], "bottom-exclusive range (^..) works (1)";
35 is [2^..2], [], "bottom-exclusive range (^..) works (2)";
36 is [3^..2], [], "bottom-exclusive auto-rev range (^..) works (3)";
37 is [1 ..^9], [1..8], "top-exclusive range (..^) works (1)";
38 is [2 ..^2], [], "top-exclusive range (..^) works (2)";
39 is [3 ..^2], [], "top-exclusive auto-rev range (..^) works (3)";
40 is [1^..^9], [2..8], "double-exclusive range (^..^) works (1)";
41 is [9^..^1], [], "double-exclusive auto-rev range (^..^) works (2)";
42 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
43
44 # tests of (x ^..^ x) here and below ensure that our implementation
45 # of double-exclusive range does not blindly remove an element
46 # from the head and tail of a list
47 is [1^..^1], [], "double-exclusive range (x ^..^ x) where x is an int";
48
49 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
50 is ["z"^.."a"], [], "bottom-exclusive string auto-rev range (^..) works";
9a58617 [gsoc_spectest] reorganization and a few more tests for ===, eqv, and…
Auzon authored
51 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
52 is ["z"..^"a"], [], "top-exclusive string auto-rev range (..^) works";
9a58617 [gsoc_spectest] reorganization and a few more tests for ===, eqv, and…
Auzon authored
53 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
54 is ["z"^..^"a"], [], "double-exclusive string auto-rev range (^..^) works";
9a58617 [gsoc_spectest] reorganization and a few more tests for ===, eqv, and…
Auzon authored
55 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
56 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
57 is ['a' ^..^ 'a'], [], "double-exclusive range (x ^..^ x) where x is a char";
58
59 is 1.5 ~~ 1^..^2, Bool::True, "lazy evaluation of the range operator", :todo<bug>;
60
61 # Test the unary ^ operator
62 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
63 is [^1], [0], "unary ^ on the boundary ^1 works";
64 is [^0], [], "unary ^0 produces null range";
65 is [^-1], [], "unary ^-1 produces null range";
66 is [^0.1], [0], "unary ^0.1 produces the range 0..^x where 0 < x < 1";
67 is [^'a'], [], "unary ^'a' produces null range";
9a58617 [gsoc_spectest] reorganization and a few more tests for ===, eqv, and…
Auzon authored
68
ba2d31c [spec] fudged and corrected range.t
moritz authored
69 {
70 # Test with floats
71 # 2006-12-05:
72 # 16:16 <TimToady> ~(1.9 ^..^ 4.9) should produce 2.9, 3.9
73 # 16:17 <pmichaud> and ~(1.9 ^..^ 4.5) would produce the same?
74 # 16:17 <TimToady> yes
75 is ~(1.1 .. 4) , "1.1 2.1 3.1", "range with float .min";
76 is ~(1.9 .. 4) , "1.9 2.9 3.9", "range with float .min";
77 is ~(1.1 ^.. 4), "2.1 3.1" , "bottom exclusive range of float";
78 is ~(1.9 ^.. 4), "2.9 3.9" , "bottom exclusive range of float";
79
80 is ~(1 .. 4.1) , "1 2 3 4", "range with float .max";
81 is ~(1 .. 4.9) , "1 2 3 4", "range with float .max";
82 is ~(1 ..^ 4.1), "1 2 3 4", "top exclusive range of float";
83 is ~(1 ..^ 4.9), "1 2 3 4", "top exclusive range of float";
84
85 is ~(1.1 .. 4.1), "1.1 2.1 3.1 4.1", "range with float .min/.max";
86 is ~(1.9 .. 4.1), "1.9 2.9 3.9" , "range with float .min/.max";
87 is ~(1.1 .. 4.9), "1.1 2.1 3.1 4.1", "range with float .min/.max";
88 is ~(1.9 .. 4.9), "1.9 2.9 3.9 4.9", "range with float .min/.max";
89
90 is ~(1.1 ^..^ 4.1), "2.1 3.1" , "both exclusive float range";
91 is ~(1.9 ^..^ 4.1), "2.9 3.9" , "both exclusive float range";
92 is ~(1.1 ^..^ 4.9), "2.1 3.1 4.1", "both exclusive float range";
93 is ~(1.9 ^..^ 4.9), "2.9 3.9" , "both exclusive float range";
94 is [1.1 ^..^ 1.1], [], "double-exclusive range (x ^..^ x) where x is a float";
95 }
9a58617 [gsoc_spectest] reorganization and a few more tests for ===, eqv, and…
Auzon authored
96
97 # Test that the operands are forced to scalar context
748e055 S03-operators/range.t: Add note about use of @array as arguments to …
pmichaud authored
98 ## From pmichaud 2006-06-30: These tests may be incorrect.
99 ## C<@one> in ## item context returns an Array, not a number
100 ## -- use C< +@one > to get the number of elements. So, we
101 ## need to either declare that there's a version of infix:<..>
102 ## that coerces its arguments to numeric context, or we can
103 ## remove these tests from the suite.
ba2d31c [spec] fudged and corrected range.t
moritz authored
104 #?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
105 {
106 my @one = (1,);
107 my @three = (1, 1, 1);
108
109 is ~(@one .. 3) , "1 2 3", "lower inclusive limit is in scalar context";
110 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
111 is ~(3 ^.. @one) , "" , "lower exclusive limit is in scalar context";
9a58617 [gsoc_spectest] reorganization and a few more tests for ===, eqv, and…
Auzon authored
112 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
113 is ~(4 .. @three) , "" , "upper inclusive limit is in scalar context";
9a58617 [gsoc_spectest] reorganization and a few more tests for ===, eqv, and…
Auzon authored
114 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
115 is ~(4 ..^ @three) , "" , "upper exclusive limit is in scalar context";
9a58617 [gsoc_spectest] reorganization and a few more tests for ===, eqv, and…
Auzon authored
116 is ~(@one .. @three), "1 2 3", "both inclusive limits are in scalar context";
117 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
118 is ~(@one ^..^ @three), "2" , "both exclusive limits are in scalar context";
119 is ~(@three ^..^ @one), "" , "both exclusive limits are in scalar context";
9a58617 [gsoc_spectest] reorganization and a few more tests for ===, eqv, and…
Auzon authored
120 }
121
122 # For tests involving :by, see t/operators/adverbial_modifiers.t
Something went wrong with that request. Please try again.