aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2017-04-25 09:52:04 +0200
committerPatrick Spek <p.spek@tyil.nl>2017-04-25 09:54:38 +0200
commit1040a65e6416d4a9c7f758093d4b17f684e1ddbe (patch)
treeebf9d2e34a5ce5e8bfa2eba99ea65692d1de4958
parentcb5db41329c1aab1cb56d7a3e381c53d668af844 (diff)
Rename to Hash::Merge
-rw-r--r--META6.json26
-rw-r--r--lib/Hash/Merge.pm6 (renamed from lib/mergehash.pm6)0
-rw-r--r--readme.md2
-rw-r--r--t/01-thing.t19
4 files changed, 41 insertions, 6 deletions
diff --git a/META6.json b/META6.json
index 4127794..93f0e07 100644
--- a/META6.json
+++ b/META6.json
@@ -1,3 +1,25 @@
{
- "license": "Artistic-2.0"
-} \ No newline at end of file
+ "perl": "6",
+ "name": "Hash::Merge",
+ "version": "1.0.0",
+ "auth": "github:scriptkitties",
+ "description": "Module to add deep merge functionality to Hashes",
+ "license": "Artistic-2.0",
+ "depends": [
+ ],
+ "provides": {
+ "Hash::Merge": "lib/Hash/Merge.pm6"
+ },
+ "authors": [
+ "Samantha McVey <samantham@posteo.net>",
+ "Patrick Spek <p.spek@tyil.work>"
+ ],
+ "tags": [
+ "hash",
+ "utils"
+ ],
+ "test-depends": [
+ "Test::META"
+ ],
+ "source-url": "https://github.com/scriptkitties/p6-Hash-Merge.git"
+}
diff --git a/lib/mergehash.pm6 b/lib/Hash/Merge.pm6
index b24f25d..b24f25d 100644
--- a/lib/mergehash.pm6
+++ b/lib/Hash/Merge.pm6
diff --git a/readme.md b/readme.md
new file mode 100644
index 0000000..9efc62f
--- /dev/null
+++ b/readme.md
@@ -0,0 +1,2 @@
+# Hash::Merge
+Module to add deep merge functionality to Hashes.
diff --git a/t/01-thing.t b/t/01-thing.t
index 68b092e..4741929 100644
--- a/t/01-thing.t
+++ b/t/01-thing.t
@@ -1,42 +1,53 @@
-#!/usr/bin/env perl6
+#! /usr/bin/env perl6
+
use v6;
use lib 'lib';
-use mergehash;
use Test;
+
+use Hash::Merge;
+
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, :no-append-array);
+
is-deeply %z, ${:y(${:p($(5, 4, 6, 7))})}, "no-append-array (replaces the instead)";
}