Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 87 lines (69 sloc) 3.407 kb
726db96 [gsoc_spectest] many, many context listops/function tests added. fudged ...
Auzon authored
1 use v6;
2
3 use Test;
4
af2da6b [context.t] don't allow listop sigils any more
lwall authored
5 plan 30;
726db96 [gsoc_spectest] many, many context listops/function tests added. fudged ...
Auzon authored
6
7 # L<S03/List prefix precedence/The list contextualizer>
8
9 {
10 my $a = 3;
11 my $b = 2;
12 my $c = 1;
13
14 # I'm not sure that smart matching is the best operation for comparison here
15 # There might be a more specific way to check that prevents false matching
181c018 [t/spec]: Use isa_ok instead of WHAT to test types.
pmichaud authored
16 isa_ok(list($a).WHAT, List, 'list(values) returns nothing more than a List');
2d1663b [t/spec] Fudging for context.t.
jnthn authored
17 #?rakudo todo 'Ongoing list-y spec changes; this test maybe is no longer valid'
181c018 [t/spec]: Use isa_ok instead of WHAT to test types.
pmichaud authored
18 isa_ok(@($a).WHAT, List, '@(values) returns nothing more than a List');
19 isa_ok((list $a).WHAT, List, '(list values) returns nothing more than a List');
af7cfd1 Remove some #?rakudo skip markers for sigil contextualizers.
pmichaud authored
20
726db96 [gsoc_spectest] many, many context listops/function tests added. fudged ...
Auzon authored
21 # These are all no-ops but still need to work correctly
181c018 [t/spec]: Use isa_ok instead of WHAT to test types.
pmichaud authored
22 isa_ok(list($a, $b, $c).WHAT, List, 'list(values) returns nothing more than a List');
23 isa_ok(@($a, $b, $c).WHAT, List, '@(values) returns nothing more than a List');
24 isa_ok((list $a, $b, $c).WHAT, List, '(list values) returns nothing more than a List');
726db96 [gsoc_spectest] many, many context listops/function tests added. fudged ...
Auzon authored
25 is((list $a, $b, $c), ($a, $b, $c), 'list($a, $b, $c) is ($a, $b, $c)');
a6cebf5 [gsoc_spectest] fixed context.t to have the proper number of tests (now ...
Auzon authored
26 is(@($a, $b, $c), ($a, $b, $c), '@($a, $b, $c) is ($a, $b, $c)');
726db96 [gsoc_spectest] many, many context listops/function tests added. fudged ...
Auzon authored
27
28 # Test the only difference between @() and list()
29 is(list(), (), 'list() should return an empty list');
30 'foo' ~~ /oo/; # run a regex so we have $/ below
2d1663b [t/spec] Fudging for context.t.
jnthn authored
31 #?rakudo skip '@()'
a6cebf5 [gsoc_spectest] fixed context.t to have the proper number of tests (now ...
Auzon authored
32 is(@(), @($/), '@() should be the same as @($/)');
726db96 [gsoc_spectest] many, many context listops/function tests added. fudged ...
Auzon authored
33 }
34
35 # L<S03/List prefix precedence/The item contextualizer>
36 # L<S02/Lists/To force a non-flattening item context>
37
38 {
39 my $a = 3;
40 my $b = 2;
41
d511e2d [spec] Explicitly stringify .WHAT result to avoid 'use uninitialised var...
bacek authored
42 is(~(item $a).WHAT, ~$a.WHAT, '(item $a).WHAT matches $a.WHAT');
726db96 [gsoc_spectest] many, many context listops/function tests added. fudged ...
Auzon authored
43 is((item $a), $a, 'item $a is just $a');
44 is(item($a), $a, 'item($a) is just $a');
45 is($($a), $a, '$($a) is just $a');
46
2d1663b [t/spec] Fudging for context.t.
jnthn authored
47 isa_ok((item $a, $b).WHAT, Seq, '(item $a, $b) makes a Seq');
48 isa_ok(item($a, $b).WHAT, Seq, 'item $a, $b makes a Seq');
49 isa_ok($($a, $b).WHAT, Seq, '$ $a, $b makes a Seq');
a6cebf5 [gsoc_spectest] fixed context.t to have the proper number of tests (now ...
Auzon authored
50 my @array = ($a, $b);
726db96 [gsoc_spectest] many, many context listops/function tests added. fudged ...
Auzon authored
51 is((item $a, $b), @array, 'item($a, $b) is the same as <<$a $b>> in an array');
52 }
53
54 {
55 # Most of these tests pass in Rakudo, but we must compare with
56 # eqv instead of eq, since the order of hashes is not guaranteed
57 # with eq. eqv does guarantee the order.
58 # also, we assign to a hash since rakudo does not recognize
59 # {} as a hash constructor and () does not make a hash
a6cebf5 [gsoc_spectest] fixed context.t to have the proper number of tests (now ...
Auzon authored
60 ok(%('a', 1, 'b', 2) eqv {a => 1, b => 2}, '%(values) builds a hash');
61 ok(hash('a', 1, 'b', 2) eqv {a => 1, b => 2}, 'hash(values) builds a hash');
62 ok((hash 'a', 1, 'b', 2) eqv {a => 1, b => 2}, 'hash values builds a hash');
2d1663b [t/spec] Fudging for context.t.
jnthn authored
63 #?rakudo todo 'hash of one element dies'
726db96 [gsoc_spectest] many, many context listops/function tests added. fudged ...
Auzon authored
64 eval_dies_ok('hash("a")', 'building a hash of one item fails');
65 }
b877b80 [gsoc_spectest] Added more cmp, leg, and <=> tests. Tested the values of...
Auzon authored
66
3152b01 [t] some updates to README, and fixed all but one smartlink in t/spec/
moritz authored
67 # L<S03/"Changes to Perl 5 operators"/Perl 5's ${...}, @{...}, %{...}, etc>
68 # ^ non-breaking space
b877b80 [gsoc_spectest] Added more cmp, leg, and <=> tests. Tested the values of...
Auzon authored
69 # Deprecated P5 dereferencing operators:
70 {
71 my $scalar = 'abcd';
72 eval_dies_ok('${$scalar}', 'Perl 5 form of ${$scalar} dies');
73
74 my $array = [1, 2, 3];
75 eval_dies_ok('@{$array}', 'Perl 5 form of @{$array} dies');
76
77 my $hash = {a => 1, b => 2, c => 3};
78 eval_dies_ok('%{$hash}', 'Perl 5 form of %{$hash} dies');
79 }
af2da6b [context.t] don't allow listop sigils any more
lwall authored
80
81 eval_dies_ok('$', 'Anonymous variable outside of declaration');
82 eval_dies_ok('@', 'Anonymous variable outside of declaration');
83 eval_dies_ok('%', 'Anonymous variable outside of declaration');
84 eval_dies_ok('&', 'Anonymous variable outside of declaration');
7f29bc5 [t/spec] Add vim: lines everywhere.
kyle authored
85
86 # vim: ft=perl6
Something went wrong with that request. Please try again.