aboutsummaryrefslogtreecommitdiff
path: root/t/01-thing.rakutest
diff options
context:
space:
mode:
Diffstat (limited to 't/01-thing.rakutest')
-rw-r--r--t/01-thing.rakutest56
1 files changed, 56 insertions, 0 deletions
diff --git a/t/01-thing.rakutest b/t/01-thing.rakutest
new file mode 100644
index 0000000..46c8055
--- /dev/null
+++ b/t/01-thing.rakutest
@@ -0,0 +1,56 @@
+#! /usr/bin/env raku
+
+use v6;
+use lib 'lib';
+use Test;
+
+use Hash::Merge::Augment;
+
+my %a;
+my %b;
+
+%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}};
+
+{
+ my (%z, %y);
+
+ %z<y><p> = (1,2,3,4);
+ %y<y><p> = (5,4,6,7);
+
+ %z.merge(%y);
+
+ is %z, {y => {p => [1, 2, 3, 4, 5, 4, 6, 7]}}, "appends arrays";
+}
+
+{
+ my (%z, %y);
+
+ %z<y><p> = (1,2,3,4);
+ %y<y><p> = (5,4,6,7);
+
+ %z.merge(%y, :!positional-append);
+
+ is-deeply %z, ${:y(${:p($(5, 4, 6, 7))})}, ":!positional-append makes lists overwrite";
+}
+
+done-testing;
+
+# vim: ft=raku ts=4 sw=4 et