Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 256 lines (209 sloc) 7.768 kb
b995a664 »
2008-09-02 [t] move context_forcers.t to spec/
1 use v6;
2
3 use Test;
4
4ea3b291 »
2013-08-31 Some skip/todo fudges and some new tests
5 plan 97;
68c6a433 »
2010-03-08 [t/spec] work on context-forcers.t: use stricter comparison; test tha…
6
7 #?DOES 1
8 sub iis(Mu $a, Mu $b, $descr) {
9 unless ok($a === $b, $descr) {
10 diag "Got: " ~ $a.perl;
11 diag "Expected: " ~ $b.perl;
12 }
13
14 }
b995a664 »
2008-09-02 [t] move context_forcers.t to spec/
15
16 { # L<S03/"Changes to Perl 5 operators"/imposes boolean context/>
68c6a433 »
2010-03-08 [t/spec] work on context-forcers.t: use stricter comparison; test tha…
17 iis ?True, True, "? context forcer works (1)";
18 iis ?False, False, "? context forcer works (2)";
b995a664 »
2008-09-02 [t] move context_forcers.t to spec/
19
68c6a433 »
2010-03-08 [t/spec] work on context-forcers.t: use stricter comparison; test tha…
20 iis ?1, True, "? context forcer works (3)";
21 iis ?0, False, "? context forcer works (4)";
22 iis ?(?1), True, "? context forcer works (5)";
23 iis ?(?0), False, "? context forcer works (6)";
b995a664 »
2008-09-02 [t] move context_forcers.t to spec/
24
68c6a433 »
2010-03-08 [t/spec] work on context-forcers.t: use stricter comparison; test tha…
25 iis ?"hi", True, "? context forcer works (7)";
26 iis ?"", False, "? context forcer works (8)";
27 iis ?(?"hi"), True, "? context forcer works (9)";
28 iis ?(?""), False, "? context forcer works (10)";
b995a664 »
2008-09-02 [t] move context_forcers.t to spec/
29
68c6a433 »
2010-03-08 [t/spec] work on context-forcers.t: use stricter comparison; test tha…
30 iis ?"3", True, "? context forcer works (11)";
31 iis ?"0", False, "? context forcer works (12)";
32 iis ?(?"3"), True, "? context forcer works (13)";
33 iis ?(?"0"), False, "? context forcer works (14)";
b995a664 »
2008-09-02 [t] move context_forcers.t to spec/
34
68c6a433 »
2010-03-08 [t/spec] work on context-forcers.t: use stricter comparison; test tha…
35 iis ?Mu, False, "? context forcer works (15)";
b995a664 »
2008-09-02 [t] move context_forcers.t to spec/
36 }
37 { # L<S02/"Names and Variables" /In boolean contexts/>
68c6a433 »
2010-03-08 [t/spec] work on context-forcers.t: use stricter comparison; test tha…
38 iis ?[], False, "? context forcer: empty container is false";
39 iis ?[1], True, "? context forcer: non-empty container is true";
b995a664 »
2008-09-02 [t] move context_forcers.t to spec/
40 }
41 { # L<SO2/"Names and Variables" /In a boolean context, a Hash/>
68c6a433 »
2010-03-08 [t/spec] work on context-forcers.t: use stricter comparison; test tha…
42 iis ?{}, False, "? context forcer: empty hash is false";
43 iis ?{:a}, True, "? context forcer: non-empty hash is true";
b995a664 »
2008-09-02 [t] move context_forcers.t to spec/
44 }
45
46 { # L<S03/"Changes to Perl 5 operators" /imposes a numeric context/>
47 is +1, 1, "+ context forcer works (1)";
48 is +0, 0, "+ context forcer works (2)";
091336dc »
2010-04-21 [t/spec] Simple tests for prefix:<+> on Rat and Complex.
49 is +(3/4), 3/4, "+ context forcer works (3)";
50 is +(3i), 3i, "+ context forcer works (4)";
4ea3b291 »
2013-08-31 Some skip/todo fudges and some new tests
51 #?pugs todo 'Mu'
52 dies_ok { +Mu }, "+ context forcer works (5)";
091336dc »
2010-04-21 [t/spec] Simple tests for prefix:<+> on Rat and Complex.
53 is +(?0), 0, "+ context forcer works (13)";
54 is +(?3), 1, "+ context forcer works (14)";
b995a664 »
2008-09-02 [t] move context_forcers.t to spec/
55 }
56
4ea3b291 »
2013-08-31 Some skip/todo fudges and some new tests
57 { # L<S03/"Changes to Perl 5 operators" /imposes a numeric context/>
58 is -1, -1, "- context forcer works (1)";
59 is -0, -0, "- context forcer works (2)";
60 is -(3/4), -3/4, "- context forcer works (3)";
61 is -(3i), -3i, "- context forcer works (4)";
62 #?pugs todo 'Mu'
63 dies_ok { -Mu }, "- context forcer works (5)";
c49992e1 »
2013-09-01 pugs fudge
64 #?pugs todo
4ea3b291 »
2013-08-31 Some skip/todo fudges and some new tests
65 is -(?0), 0, "- context forcer works (13)";
66 is -(?3), -1, "- context forcer works (14)";
67 }
68
b995a664 »
2008-09-02 [t] move context_forcers.t to spec/
69 { # L<S03/"Changes to Perl 5 operators" /imposes a string context/>
70 is ~1, "1", "~ context forcer works (1)";
71 is ~0, "0", "~ context forcer works (2)";
72 is ~"1", "1", "~ context forcer works (3)";
73 is ~"0", "0", "~ context forcer works (4)";
74 is ~"", "", "~ context forcer works (5)";
ebb9ec57 »
2012-04-24 pugs unfudge
75 #?pugs todo 'Mu'
6ef1b5d9 »
2013-09-01 niecza fudge
76 #?niecza todo 'https://github.com/sorear/niecza/issues/179'
4ea3b291 »
2013-08-31 Some skip/todo fudges and some new tests
77 dies_ok { ~Mu }, "~ context forcer works (6)";
b995a664 »
2008-09-02 [t] move context_forcers.t to spec/
78 is ~"Inf", "Inf", "~ context forcer works (7)";
79 is ~"-Inf", "-Inf", "~ context forcer works (8)";
80 is ~"NaN", "NaN", "~ context forcer works (9)";
81 is ~"3e5", "3e5", "~ context forcer works (10)";
82 }
84e0e504 »
2008-09-25 [t] merge syntax/force_context.t into spec/S03-operators/context-forc…
83
68c6a433 »
2010-03-08 [t/spec] work on context-forcers.t: use stricter comparison; test tha…
84 ok 4.Str ~~ Str, 'Int.Str returns a Str';
85
bb5077a0 »
2014-01-01 eval => EVAL in S03 and S04
86 sub eval_elsewhere($code){ EVAL($code) }
84e0e504 »
2008-09-25 [t] merge syntax/force_context.t into spec/S03-operators/context-forc…
87
88 # L<S02/Context/numeric "+">
89 # numeric (+) context
9ec03980 »
2011-12-29 Clean up a bit, and fudge for niecza.
90 #?niecza skip "Failure NYI"
545136e3 »
2012-02-25 pugs fudge
91 #?pugs skip 'Failure'
84e0e504 »
2008-09-25 [t] merge syntax/force_context.t into spec/S03-operators/context-forc…
92 {
93 my $a = '2 is my favorite number';
c008d8f7 »
2011-07-15 Fudge and fix tests relying on Str.Numeric .
94 isa_ok(+$a, Failure, 'trailing chars cause failure');
84e0e504 »
2008-09-25 [t] merge syntax/force_context.t into spec/S03-operators/context-forc…
95
96 my $b = 'Did you know that, 2 is my favorite number';
c008d8f7 »
2011-07-15 Fudge and fix tests relying on Str.Numeric .
97 isa_ok(+$b, Failure, 'it is forced into a Num');
84e0e504 »
2008-09-25 [t] merge syntax/force_context.t into spec/S03-operators/context-forc…
98 }
99
4846880f »
2008-09-29 [t/spec] fix nearly all broken smartlinks, two remain
100 # L<S03/Symbolic unary precedence/"prefix:<->">
c008d8f7 »
2011-07-15 Fudge and fix tests relying on Str.Numeric .
101 #?rakudo skip 'failure modes of Str.Numeric'
9ec03980 »
2011-12-29 Clean up a bit, and fudge for niecza.
102 #?niecza skip "Failure NYI"
545136e3 »
2012-02-25 pugs fudge
103 #?pugs skip 'Failure'
84e0e504 »
2008-09-25 [t] merge syntax/force_context.t into spec/S03-operators/context-forc…
104 {
105 my $a = '2 is my favorite number';
c008d8f7 »
2011-07-15 Fudge and fix tests relying on Str.Numeric .
106 isa_ok(-$a, Failure, 'trailing chars cause failure');
84e0e504 »
2008-09-25 [t] merge syntax/force_context.t into spec/S03-operators/context-forc…
107
108 my $b = 'Did you know that, 2 is my favorite number';
c008d8f7 »
2011-07-15 Fudge and fix tests relying on Str.Numeric .
109 ok(-$b, Failure, 'it is forced into a Num');
84e0e504 »
2008-09-25 [t] merge syntax/force_context.t into spec/S03-operators/context-forc…
110 }
111
112 # L<S02/Context/string "~">
113 # L<S03/Changes to Perl 5 operators/Unary ~ string context>
114 # string context
545136e3 »
2012-02-25 pugs fudge
115 #?pugs skip 'Stringy'
84e0e504 »
2008-09-25 [t] merge syntax/force_context.t into spec/S03-operators/context-forc…
116 {
117 my $a = 10.500000;
9ec03980 »
2011-12-29 Clean up a bit, and fudge for niecza.
118 #?niecza skip "Stringy NYI"
77fc5a73 »
2009-11-22 [t/spec] more Str -> Stringy changes
119 ok(~$a ~~ Stringy, 'it is forced into a Str');
84e0e504 »
2008-09-25 [t] merge syntax/force_context.t into spec/S03-operators/context-forc…
120 is(~$a, '10.5', 'forced into string context');
121
122 my $b = -100;
9ec03980 »
2011-12-29 Clean up a bit, and fudge for niecza.
123 #?niecza skip "Stringy NYI"
77fc5a73 »
2009-11-22 [t/spec] more Str -> Stringy changes
124 ok(~$b ~~ Stringy, 'it is forced into a Str');
84e0e504 »
2008-09-25 [t] merge syntax/force_context.t into spec/S03-operators/context-forc…
125 is(~$b, '-100', 'forced into string context');
126
127 my $c = -100.1010;
9ec03980 »
2011-12-29 Clean up a bit, and fudge for niecza.
128 #?niecza skip "Stringy NYI"
77fc5a73 »
2009-11-22 [t/spec] more Str -> Stringy changes
129 ok(~$c ~~ Stringy, 'it is forced into a Str');
84e0e504 »
2008-09-25 [t] merge syntax/force_context.t into spec/S03-operators/context-forc…
130 is(~$c, '-100.101', 'forced into string context');
131 }
132
133 # L<S02/Context/boolean "?">
134 # L<S03/Changes to Perl 5 operators/"?" imposes boolean context>
135 # boolean context
136 {
137 my $a = '';
138 isa_ok(?$a, Bool, 'it is forced into a Bool');
139 ok(!(?$a), 'it is forced into boolean context');
140
141 my $b = 'This will be true';
142 isa_ok(?$b, Bool, 'it is forced into a Bool');
143 ok(?$b, 'it is forced into boolean context');
144
145 my $c = 0;
146 isa_ok(?$c, Bool, 'it is forced into a Bool');
147 ok(!(?$c), 'it is forced into boolean context');
148
149 my $d = 1;
150 isa_ok(?$d, Bool, 'it is forced into a Bool');
151 ok(?$d, 'it is forced into boolean context');
bc8cfdee »
2008-09-25 [t/spec] fudged context-forcers.t for rakudo
152 }
84e0e504 »
2008-09-25 [t] merge syntax/force_context.t into spec/S03-operators/context-forc…
153
2d48e362 »
2013-07-26 Fix tests relating to "is context", which apparently now is "is dynamic"
154 #?niecza skip 'Trait dynamic not available on variables'
bc8cfdee »
2008-09-25 [t/spec] fudged context-forcers.t for rakudo
155 {
2d48e362 »
2013-07-26 Fix tests relating to "is context", which apparently now is "is dynamic"
156 my $arrayref is dynamic = list(1,2,3);
157 my $boo is dynamic = 37;
158 ok eval_elsewhere('?(@$*arrayref)'), '?(@$arrayref) syntax works';
159 ok eval_elsewhere('?(@($*arrayref))'), '?(@($arrayref)) syntax works';
84e0e504 »
2008-09-25 [t] merge syntax/force_context.t into spec/S03-operators/context-forc…
160 }
161
4846880f »
2008-09-29 [t/spec] fix nearly all broken smartlinks, two remain
162 # L<S03/Symbolic unary precedence/"prefix:<!>">
84e0e504 »
2008-09-25 [t] merge syntax/force_context.t into spec/S03-operators/context-forc…
163 {
164 my $a = '';
165 isa_ok(!$a, Bool, 'it is forced into a Bool');
166 ok(!$a, 'it is forced into boolean context');
167
168 my $b = 'This will be true';
169 isa_ok(!$b, Bool, 'it is forced into a Bool');
170 ok(!(!$b), 'it is forced into boolean context');
171
172 my $c = 0;
173 isa_ok(!$c, Bool, 'it is forced into a Bool');
174 ok(!$c, 'it is forced into boolean context');
175
176 my $d = 1;
177 isa_ok(!$d, Bool, 'it is forced into a Bool');
178 ok(!(!$d), 'it is forced into boolean context');
179
bc8cfdee »
2008-09-25 [t/spec] fudged context-forcers.t for rakudo
180 }
9ec03980 »
2011-12-29 Clean up a bit, and fudge for niecza.
181 #?niecza skip 'Trait context not available on variables'
bc8cfdee »
2008-09-25 [t/spec] fudged context-forcers.t for rakudo
182 {
2d48e362 »
2013-07-26 Fix tests relating to "is context", which apparently now is "is dynamic"
183 my $arrayref is dynamic = list(1,2,3);
84e0e504 »
2008-09-25 [t] merge syntax/force_context.t into spec/S03-operators/context-forc…
184
2d48e362 »
2013-07-26 Fix tests relating to "is context", which apparently now is "is dynamic"
185 ok eval_elsewhere('!(!(@$*arrayref))'), '!(@$arrayref) syntax works';
186 ok eval_elsewhere('!(!(@($*arrayref)))'), '!(@($arrayref)) syntax works';
84e0e504 »
2008-09-25 [t] merge syntax/force_context.t into spec/S03-operators/context-forc…
187 }
188
189 # int context
e84b8181 »
2009-09-15 Kill off prefix:<int> (as per r25890)
190 # tested in t/spec/S32-num/int.t
1d861192 »
2008-11-04 [t/spec] tests for @() context forcers, patch courtesy by rindolf++
191
192 {
193 my $x = [0, 100, 280, 33, 400, 5665];
194
9ec03980 »
2011-12-29 Clean up a bit, and fudge for niecza.
195 is @($x)[1], 100, '@$x works';
1d861192 »
2008-11-04 [t/spec] tests for @() context forcers, patch courtesy by rindolf++
196
9ec03980 »
2011-12-29 Clean up a bit, and fudge for niecza.
197 is @($x)[3]+50, 83, '@$x works inside a larger expression';
1d861192 »
2008-11-04 [t/spec] tests for @() context forcers, patch courtesy by rindolf++
198
199 my $y = [601, 700, 888];
200
201 my @total = (@$x, @$y);
202
9ec03980 »
2011-12-29 Clean up a bit, and fudge for niecza.
203 is @total[0], 0, "total[0] is 0";
204 is @total[1], 100, "total[1] is 100";
205 is @total[6], 601, "total[6] is 601";
206 is @total[8], 888, "total[8] is 888";
1d861192 »
2008-11-04 [t/spec] tests for @() context forcers, patch courtesy by rindolf++
207 }
208
9ec03980 »
2011-12-29 Clean up a bit, and fudge for niecza.
209 #?niecza skip 'Unmatched key in Hash.LISTSTORE'
77134ae3 »
2010-08-23 [t/spec] tests for %() hash context forcer; also tests RT #75502
210 {
211 ok %() ~~ Hash, '%() returns a Hash';
212 is +%(), 0, '%() is an empty Hash';
9ec03980 »
2011-12-29 Clean up a bit, and fudge for niecza.
213 }
214
545136e3 »
2012-02-25 pugs fudge
215 #?pugs skip 'Cannot cast into a Hash'
9ec03980 »
2011-12-29 Clean up a bit, and fudge for niecza.
216 {
77134ae3 »
2010-08-23 [t/spec] tests for %() hash context forcer; also tests RT #75502
217 my $x = %(a => 3, b => 5);
218 is $x<a>, 3, 'hash constructor worked (1)';
219 is $x<b>, 5, 'hash constructor worked (1)';
73394770 »
2010-09-05 [context-forcers.t] test depended on hash key order
220 is $x.keys.sort.join(', '), 'a, b', 'hash constructor produced the right keys';
77134ae3 »
2010-08-23 [t/spec] tests for %() hash context forcer; also tests RT #75502
221 }
222
b0c868ba »
2008-11-25 [t/spec] tests for prefix:<^>
223 # the "upto" operator
224 # L<S03/Symbolic unary precedence/"prefix:<^>">
225
226 # ^$x is the range 0 .. ($x -1)
227 {
545136e3 »
2012-02-25 pugs fudge
228 #?pugs todo
b0c868ba »
2008-11-25 [t/spec] tests for prefix:<^>
229 ok 0 ~~ ^10, '0 is in ^10';
545136e3 »
2012-02-25 pugs fudge
230 #?pugs todo
b0c868ba »
2008-11-25 [t/spec] tests for prefix:<^>
231 ok 9 ~~ ^10, '9 is in ^10';
545136e3 »
2012-02-25 pugs fudge
232 #?pugs todo
b0c868ba »
2008-11-25 [t/spec] tests for prefix:<^>
233 ok 9.9 ~~ ^10, '9.99 is in ^10';
234 ok 10 !~~ ^10, '10 is not in ^10';
235 is (^10).elems, 10, '^10 has 10 elems';
545136e3 »
2012-02-25 pugs fudge
236 #?pugs skip 'Range'
207f13f6 »
2008-12-25 [t] and [t/spec]
237 isa_ok ^10, Range;
b0c868ba »
2008-11-25 [t/spec] tests for prefix:<^>
238
239 # now the same for ^@array, in which case prefix:<^>
240 # imposes numeric context
241
242 my @a = <one two three four five six seven eight nine ten>;
545136e3 »
2012-02-25 pugs fudge
243 #?pugs todo
b0c868ba »
2008-11-25 [t/spec] tests for prefix:<^>
244 ok 0 ~~ ^@a, '0 is in ^10';
545136e3 »
2012-02-25 pugs fudge
245 #?pugs todo
b0c868ba »
2008-11-25 [t/spec] tests for prefix:<^>
246 ok 9 ~~ ^@a, '9 is in ^10';
545136e3 »
2012-02-25 pugs fudge
247 #?pugs todo
b0c868ba »
2008-11-25 [t/spec] tests for prefix:<^>
248 ok 9.9 ~~ ^@a, '9.99 is in ^10';
6c5e1198 »
2008-11-27 [t/spec]: Unfudge tests for ^@list, correct one test.
249 ok 10 !~~ ^@a, '10 is not in ^10';
b0c868ba »
2008-11-25 [t/spec] tests for prefix:<^>
250 is (^@a).elems, 10, '^10 has 10 elems';
545136e3 »
2012-02-25 pugs fudge
251 #?pugs skip 'Range'
207f13f6 »
2008-12-25 [t] and [t/spec]
252 isa_ok ^@a, Range;
b0c868ba »
2008-11-25 [t/spec] tests for prefix:<^>
253 }
7f29bc53 »
2009-08-08 [t/spec] Add vim: lines everywhere.
254
255 # vim: ft=perl6
Something went wrong with that request. Please try again.