diff options
author | Patrick Spek <p.spek@tyil.nl> | 2018-03-28 14:19:52 +0200 |
---|---|---|
committer | Patrick Spek <p.spek@tyil.nl> | 2018-03-28 14:19:52 +0200 |
commit | da9c10a20bbbf8904f3831511538eff67c27b695 (patch) | |
tree | 60b1b2d40f7279de397ffaee47047ca550a7a3c2 | |
parent | e3e09621c15dfcd6ad66c2730e62ca5e634ddb44 (diff) | |
download | hash-merge-da9c10a20bbbf8904f3831511538eff67c27b695.tar.gz hash-merge-da9c10a20bbbf8904f3831511538eff67c27b695.tar.bz2 |
Add tests for a unit module
-rw-r--r-- | t/03-unit.t | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/t/03-unit.t b/t/03-unit.t new file mode 100644 index 0000000..43d70ff --- /dev/null +++ b/t/03-unit.t @@ -0,0 +1,59 @@ +#! /usr/bin/env perl6 + +use v6.c; + +use Hash::Merge::Unit; +use Test; + +plan 2; + +subtest "merge-hash" => { + plan 2; + + my %original = + a => "a", + b => { + c => "c" + } + ; + + my %result = + a => "a", + b => { + c => "c", + d => "d", + }, + ; + + is-deeply merge-hash(%original, %(b => %(d => "d"))), %result, "Hash merges correctly"; + is-deeply merge-hash(%original, %()), %original, "Empty Hash doesn't affect original"; +} + +subtest "merge-hashes" => { + plan 4; + + my %original = + a => "a", + b => { + c => "c" + } + ; + + my %result = + a => "a", + b => { + c => "c", + d => "d", + }, + ; + + is-deeply merge-hashes(%original), %original, "Single argument returns original"; + is-deeply merge-hashes(%original, %(b => %(d => "d"))), %result, "Hash merges correctly"; + is-deeply merge-hashes(%original, %()), %original, "Empty Hash doesn't affect original"; + + %result<b><e> = "e"; + + is-deeply merge-hashes(%original, %(b => %(d => "d")), %(b => %(e => "e"))), %result, "Hash merges correctly"; +} + +# vim: ft=perl6 ts=4 sw=4 et |