From 6d39a793ca5a2c1af57d1ea8faace53daa710929 Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Mon, 28 Oct 2019 09:41:35 +0000 Subject: [PATCH 1/2] Tidied up error message for get_currencies_for_country(). --- lib/Data/MoneyCurrency.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Data/MoneyCurrency.pm b/lib/Data/MoneyCurrency.pm index 02c8999..4c6df16 100644 --- a/lib/Data/MoneyCurrency.pm +++ b/lib/Data/MoneyCurrency.pm @@ -330,8 +330,8 @@ reference to an array of strings that are currency codes. =cut sub get_currencies_for_country { - croak "get_currency received no arguments" if @_ == 0; - croak "get_currency received more than one argument" if @_ > 1; + croak "get_currencies_for_country received no arguments" if @_ == 0; + croak "get_currencies_for_country received more than one argument" if @_ > 1; my $country = lc($_[0]); # Return shallow copy to avoid mutating $rh_currencies_for_country From b8d711765d58990630a9bbb9fe5f7a9eae50f0c1 Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Mon, 28 Oct 2019 09:52:30 +0000 Subject: [PATCH 2/2] Added basic test for no arguments. --- t/get_currencies_for_country.t | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/t/get_currencies_for_country.t b/t/get_currencies_for_country.t index 4daf83d..bb35560 100755 --- a/t/get_currencies_for_country.t +++ b/t/get_currencies_for_country.t @@ -16,4 +16,8 @@ is_deeply(get_currencies_for_country('us'), ['usd'], 'Test USA'); is_deeply(get_currencies_for_country('cu'), ['cuc', 'cup'], 'Test Cuba'); is_deeply(get_currencies_for_country('lt'), ['eur'], 'Test Lithuania'); +throws_ok { + get_currencies_for_country(); +} qr/no arguments/, "get_currencies_for_country() throws exception"; + done_testing();