Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 54 lines (39 sloc) 1.206 kb
3e06152 [t] move nested_hashrefs.t to spec
moritz authored
1 use v6;
2
3 use Test;
4
eda6db1 [t/spec] move smartlinks from POD to ordinary comments
moritz authored
5 # L<S06/Anonymous hashes vs blocks>
6
d2482f4 replace plan *; with number of tests S03-S06
mberends authored
7 plan 15;
3e06152 [t] move nested_hashrefs.t to spec
moritz authored
8
9 my $hash = {
10 '1' => { '2' => 3, '4' => 5 },
11 };
12
13
14 is( $hash<1><2>, '3', 'First nested element.');
15 is( $hash<1><4>, '5', 'Second nested element.');
16
17 my $h2 = {
18 x => [2,3]
19 };
20 is( $h2<x>[0], '2', 'First nested element.');
21 is( $h2<x>[1], '3', 'Second nested element.');
22
23 my %foo = (1 => 2);
24 my $bar = { %foo };
885130b [t/spec] todo test passes now
kyle authored
25
3e06152 [t] move nested_hashrefs.t to spec
moritz authored
26 ok $bar ~~ Hash, '%foo in a block causes hash composing';
27
4502acb [t] merge hash_sub.t into spec/
moritz authored
28
29 # pugs had problems with //= and the hash() contextualizer
30 {
31 my %hash;
32 %hash<foo> //= hash();
33 %hash<bar> //= hash;
34 my $h_ref;
35 $h_ref //= hash();
36 is(%hash<foo>.WHAT, ::Hash, "Parses as two items");
37 is(%hash<bar>.WHAT, ::Hash, "Parens do not help");
38 is($h_ref.WHAT, ::Hash, "It is not limited to hash values");
39 }
40
5870014 [t/spec] test hash vs. block distinction with leading ; and placeholders...
moritz authored
41 {
42 ok {; a => 1 } ~~ Block, '{; ... } is a Block';
43 ok { a => 1 } ~~ Hash, '{ a => 1} is a Hash';
44 ok { $^a => $^b } ~~ Block, 'placeholders force it to be a block';
45 ok { $^a => 'b' } ~~ Block, '... as a key';
46 ok { a => $^x } ~~ Block, '... as a value';
47 ok { b => 3, a => $^x, 4 => 5 } ~~ Block, '... somewhere deep inside';
d66c0c5 [t/spec] test for RT #76198, {;} should be a Block
moritz authored
48 ok {;} ~~ Block, '{;} is a Block';
5870014 [t/spec] test hash vs. block distinction with leading ; and placeholders...
moritz authored
49 }
50
e76dd4c @moritz s/done_testing/done/ as per recent S24 changes
moritz authored
51 done;
5870014 [t/spec] test hash vs. block distinction with leading ; and placeholders...
moritz authored
52
4502acb [t] merge hash_sub.t into spec/
moritz authored
53 # vim: ft=perl6
Something went wrong with that request. Please try again.