diff options
author | Samantha McVey <samantham@posteo.net> | 2017-04-24 14:49:30 -0700 |
---|---|---|
committer | Samantha McVey <samantham@posteo.net> | 2017-04-24 14:49:30 -0700 |
commit | 40d5898acdbae40c1b74370d5f007756bce4ca52 (patch) | |
tree | 48f1b7be9faae2f1e9bbc3e235708113c074433c | |
parent | 18e1a1ce36cbecd76f55ee46831a35849711d573 (diff) |
Clean up the code some
-rw-r--r-- | lib/mergehash.pm6 | 3 | ||||
-rw-r--r-- | t/01-thing.t | 15 |
2 files changed, 10 insertions, 8 deletions
diff --git a/lib/mergehash.pm6 b/lib/mergehash.pm6 index 6e84aa8..cc9b9cb 100644 --- a/lib/mergehash.pm6 +++ b/lib/mergehash.pm6 @@ -12,11 +12,9 @@ augment class Hash { elsif %merge-source{$key} ~~ Positional { my @a; for %merge-into{$key}.list { - say $_; @a.push: $_; } for %merge-source{$key}.list { - say $_; @a.push: $_; } %merge-into{$key} = @a; @@ -26,7 +24,6 @@ augment class Hash { } } else { - note 'source'; %merge-into{$key} = %merge-source{$key}; } } diff --git a/t/01-thing.t b/t/01-thing.t index 9a906a7..402c157 100644 --- a/t/01-thing.t +++ b/t/01-thing.t @@ -5,27 +5,32 @@ use mergehash; use Test; my %a; my %b; -#%a<Z> = "orig"; -#%b<Z> = "new"; %a<b> = 1; %b<a> = 2; %a<y><z> = 2; %b<y><a> = 1; my %b-orig = %b; my %a-orig = %a; + + %a.merge(%b); is-deeply %b, %b-orig; is-deeply %a, {:a(2), :b(1), :y(${:a(1), :z(2)})}; + + %a = %a-orig; %b = %b-orig; %a<Z> = "orig"; %b<Z> = "new"; +%a.merge(%b); is-deeply %a, {Z => 'new', a => 2, b => 1, y => {a => 1, z => 2}}; -say %a; -my %z; + + +my (%z, %y); %z<y><p> = (1,2,3,4); -my %y; %y<y><p> = (5,4,6,7); %z.merge(%y); is %z, {y => {p => [1, 2, 3, 4, 5, 4, 6, 7]}}, "merges arrays"; + + done-testing; |