projects
/
webpac2
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
use utf-8 encoding
[webpac2]
/
t
/
1-validate.t
diff --git
a/t/1-validate.t
b/t/1-validate.t
index
8b62d47
..
5c85050
100755
(executable)
--- a/
t/1-validate.t
+++ b/
t/1-validate.t
@@
-1,31
+1,22
@@
#!/usr/bin/perl -w
use strict;
#!/usr/bin/perl -w
use strict;
-use Test::More tests => 54;
-use Test::Exception;
-use blib;
+use lib 'lib';
-use Data::Dump qw/dump/;
-use Cwd qw/abs_path/;
+use Test::More tests => 56;
BEGIN {
BEGIN {
+use_ok( 'WebPAC::Test' );
use_ok( 'WebPAC::Validate' );
}
use_ok( 'WebPAC::Validate' );
}
-my $debug = shift @ARGV;
-
-ok(my $abs_path = abs_path($0), "abs_path");
-$abs_path =~ s#/[^/]*$#/#;
-
-ok(my $v = new WebPAC::Validate(
- debug => $debug,
-), "new witout path");
+ok(my $v = new WebPAC::Validate(%LOG), "new witout path");
ok( ! $v->{rules}, 'no path' );
ok( ! $v->{rules}, 'no path' );
-ok(
my
$v = new WebPAC::Validate(
+ok($v = new WebPAC::Validate(
path => "$abs_path/data/validate_test",
path => "$abs_path/data/validate_test",
-
debug => $debug
,
+
%LOG
,
), "new with path");
ok($v->{rules}, "rules exist");
), "new with path");
ok($v->{rules}, "rules exist");
@@
-37,6
+28,7
@@
is_deeply( $v->{rules}, {
'903' => [ 'a', 'b', 'c' ],
'904' => [ 'a' ],
'905' => [ 'a*' ],
'903' => [ 'a', 'b', 'c' ],
'904' => [ 'a' ],
'905' => [ 'a*' ],
+ '906' => [ '0' ],
}, 'simple rules parsed');
diag dump( $v ) if ( $debug );
}, 'simple rules parsed');
diag dump( $v ) if ( $debug );
@@
-60,6
+52,7
@@
is_deeply( $v->{rules}, {
'903' => [ 'a', 'b', 'c' ],
'904' => [ 'a' ],
'905' => [ 'a*' ],
'903' => [ 'a', 'b', 'c' ],
'904' => [ 'a' ],
'905' => [ 'a*' ],
+ '906' => [ '0' ],
}, 'rules');
ok($v->{rules}, "rules exist");
}, 'rules');
ok($v->{rules}, "rules exist");
@@
-89,7
+82,7
@@
sub test_v {
if (ref($tmp) eq 'HASH') {
return $tmp;
} else {
if (ref($tmp) eq 'HASH') {
return $tmp;
} else {
- diag "explanation: $tmp";
+ diag "explanation: $tmp"
if $debug
;
}
}
} else {
}
}
} else {
@@
-161,6
+154,14
@@
test_v({
'905' => [ ]
});
'905' => [ ]
});
+test_v({
+ '906' => [ ]
+});
+
+test_v({
+ '906' => [ { '0' => 'foo' } ]
+});
+
my $expected_error = {
900 => { not_repeatable => "probably bug in parsing input data" },
901 => { missing_subfield => "a required", "dump" => "baz" },
my $expected_error = {
900 => { not_repeatable => "probably bug in parsing input data" },
901 => { missing_subfield => "a required", "dump" => "baz" },