Commits

Anonymous committed 1af530d

Added Test for args token not being specified, and tests for the warnings it throws

Comments (0)

Files changed (2)

modules/Text-Sprintf-Named/lib/Text/Sprintf/Named.pm

 
     my $args = shift || {};
 
+    if ( (scalar keys %{$args}) > 0  && not exists $args->{args} ){
+        warnings::warnif( $self, 'Format parameters were specified, but none of them were \'args\', this is probably a mistake.' );
+    }
+
     my $named_params = $args->{args} || {};
 
     my $format = $self->_fmt;

modules/Text-Sprintf-Named/t/03-incomplete.t

 use strict;
 use warnings;
 
-use Test::More tests => 6;
+use Test::More tests => 8;
 use Test::Warn;
 use Text::Sprintf::Named;
 
 
 warnings_like { $obj->format() }[qr/numeric.*sprintf/],
   '[Subdued] Missing Token Throws Warning ( Float )';
+
+#Test 7
+
+$obj = Text::Sprintf::Named->new( { fmt => '.' } );
+
+use warnings 'Text::Sprintf::Named';
+
+warning_like {
+    $obj->format(
+        {
+            erroneous_parameter => 'this one',
+            more_error          => 'this',
+            this_will_never     => 'work',
+        }
+    );
+}
+qr/Format parameters were specified, but none/,
+  'Weird Format Parameters Throws Warning';
+
+# Test 8
+no warnings 'Text::Sprintf::Named';
+
+warnings_are {
+    $obj->format(
+        {
+            erroneous_parameter => 'this one',
+            more_error          => 'this',
+            this_will_never     => 'work',
+        }
+    );
+}
+[], '[Silenced] Weird Format Parameters Throws Warning';
+