From 6dbd522c277fd60180bc1d068b5fe3b9480549ca Mon Sep 17 00:00:00 2001 From: Samantha McVey Date: Tue, 25 Apr 2017 14:00:33 -0700 Subject: Fix tests for passing a type object hash --- lib/Hash/Merge.pm6 | 6 +++++- t/02-empty-source.t | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/Hash/Merge.pm6 b/lib/Hash/Merge.pm6 index 60551a3..d864b7f 100644 --- a/lib/Hash/Merge.pm6 +++ b/lib/Hash/Merge.pm6 @@ -15,7 +15,11 @@ augment class Hash #| Use :no-append-array to replace arrays and positionals instead, which will #| also retain the original type and not convert to an Array #| - method merge (%b; Bool:D :$no-append-array = False) + multi method merge (Hash:U: %b, Bool:D :$no-append-array = False) { + warn "Cannot merge an undefined Hash!"; + return %b; + } + multi method merge (Hash:D: %b, Bool:D :$no-append-array = False) { hashmerge self, %b, :$no-append-array; } diff --git a/t/02-empty-source.t b/t/02-empty-source.t index 684a98b..b404a63 100644 --- a/t/02-empty-source.t +++ b/t/02-empty-source.t @@ -4,7 +4,7 @@ use v6.c; use lib 'lib'; use Test; -plan 2; +plan 3; use Hash::Merge; @@ -23,6 +23,6 @@ is-deeply $empty, $hash, "Merge into empty hash"; my Hash $nil; -$nil.merge($hash); -is-deeply $nil, $hash, "Merge into uninitialized hash"; +throws-like $nil.merge($hash), Exception, "Merge into uninitialized hash"; +is-deeply $nil.merge($hash), $hash, "Returns supplied hash if it throws"; -- cgit v1.1