Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 38 lines (28 sloc) 0.963 kB
e0d750f tests for Hash.push
moritz authored
1 use v6;
2 use Test;
915e4be @colomon Test pushing non-Str-keyed things onto a Hash.
colomon authored
3 plan 7;
e0d750f tests for Hash.push
moritz authored
4
d154816 [t/spec] more smartlink fixing
moritz authored
5 # L<S32::Containers/Hash/"Like hash assignment insofar">
e0d750f tests for Hash.push
moritz authored
6
7 my %ref1 = (a => 1, b => 2, c => 3);
8 my %ref2 = (a => [1, 4, 5], b => 2, c => 3);
9
10 {
77ad197 @perlpilot [push.t] Hash.push should return a Hash
perlpilot authored
11
12 my ($r, %x);
13 $r = %x.push: 'a' => 1;
f85b8bf Fix a bunch of typeobject stringifications.
kboga authored
14 is $r.WHAT.gist, Hash.gist, 'Hash.push returns hash';
77ad197 @perlpilot [push.t] Hash.push should return a Hash
perlpilot authored
15
e0d750f tests for Hash.push
moritz authored
16 my %h;
17 %h.push: 'b', 2, 'a', 1, 'c', 3;
a87fde4 @lizmat s/is_deeply/is-deeply/g
lizmat authored
18 is-deeply %h, %ref1, 'basic Hash.push with alternating items';
e0d750f tests for Hash.push
moritz authored
19 %h.push: (:a(4), :a(5));
a87fde4 @lizmat s/is_deeply/is-deeply/g
lizmat authored
20 is-deeply %h, %ref2, 'stacking push works with pairs';
e0d750f tests for Hash.push
moritz authored
21
22 my %g;
23 %g.push: (a => 1), (c => 3), (b => 2);
a87fde4 @lizmat s/is_deeply/is-deeply/g
lizmat authored
24 is-deeply %g, %ref1, 'basic Hash.push with pairs ';
e0d750f tests for Hash.push
moritz authored
25 %g.push: 'a', 4, 'a', 5;
a87fde4 @lizmat s/is_deeply/is-deeply/g
lizmat authored
26 is-deeply %g, %ref2, 'stacking push worsk with alternating items';
915e4be @colomon Test pushing non-Str-keyed things onto a Hash.
colomon authored
27
28 my %hh;
29 %hh.push: 5, 'bar';
a87fde4 @lizmat s/is_deeply/is-deeply/g
lizmat authored
30 is-deeply %hh, { 5 => 'bar' }, 'Hash.push works pushing a non-Str-keyed alternating items';
915e4be @colomon Test pushing non-Str-keyed things onto a Hash.
colomon authored
31
32 my %gg;
33 %gg.push: 5 => 'bar';
a87fde4 @lizmat s/is_deeply/is-deeply/g
lizmat authored
34 is-deeply %gg, { 5 => 'bar' }, 'Hash.push works pushing a non-Str-keyed Pair';
e0d750f tests for Hash.push
moritz authored
35 }
36
37 # vim: ft=perl6
Something went wrong with that request. Please try again.