Permalink
Browse files

Die on invalid params to constructor.

Closes #3.
  • Loading branch information...
theory committed Oct 21, 2010
1 parent 2bc01cb commit 02ffa5d9aa63aeb01be54fdedb3c478e30513134
Showing with 10 additions and 2 deletions.
  1. +3 −0 Changes
  2. +1 −1 lib/Test/XPath.pm
  3. +6 −1 t/xpath.t
View
@@ -1,6 +1,9 @@
Revision history for Perl extension Test::XPath.
0.14
+ - The constructor now croaks instead of carping when no XML or HTML
+ parameter has been pased to it. Thanks to GitHub user "sshaw" for the
+ spot.
0.13 2010-06-01T18:39:28
- Added the `filter` option, which allows custom filtering of XPath
View
@@ -121,7 +121,7 @@ sub _doc {
}
require Carp;
- Carp::carp(
+ Carp::croak(
'Test::XPath->new requires the "xml", "file", or "doc" parameter'
);
}
View
@@ -1,13 +1,18 @@
#!/usr/bin/perl -w
use strict;
-use Test::More tests => 55;
+use Test::More tests => 56;
#use Test::More 'no_plan';
use File::Spec::Functions 'catfile';
use utf8;
BEGIN { use_ok 'Test::XPath' or die; }
+# Try failure.
+eval { Test::XPath->new };
+like $@, qr{Test::XPath->new requires the "xml", "file", or "doc" parameter},
+ 'Should get an exception for invalid params';
+
my $xml = '<foo xmlns="http://w3.org/ex"><bar>first</bar><bar>post</bar></foo>';
my $html = '<html><head><title>Hello</title><body><p><em><b>first</b></em></p><p><em><b>post</b></em></p></body></html>';

0 comments on commit 02ffa5d

Please sign in to comment.