more read_validate_file tests, but still not comprihensive
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 27 May 2007 19:28:18 +0000 (19:28 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 27 May 2007 19:28:18 +0000 (19:28 +0000)
git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@862 07558da8-63fa-0310-ba24-9fe276d99e06

t/1-validate.t

index 8ce74f0..70a32f9 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/perl -w
 
 use strict;
-use Test::More tests => 51;
+use Test::More tests => 54;
 use Test::Exception;
 use blib;
 
@@ -18,26 +18,41 @@ ok(my $abs_path = abs_path($0), "abs_path");
 $abs_path =~ s#/[^/]*$#/#;
 
 ok(my $v = new WebPAC::Validate(
-       path => "$abs_path/data/validate_test_simple",
+       debug => $debug,
+), "new witout path");
+
+ok( ! $v->{rules}, 'no path' );
+
+ok(my $v = new WebPAC::Validate(
+       path => "$abs_path/data/validate_test",
        debug => $debug,
 ), "new with path");
 
 ok($v->{rules}, "rules exist");
 
 is_deeply( $v->{rules}, {
-       '900' => [ 'a', 'b', 'c', 'd' ],
+       '900' => 1,
+       '901' => [ 'a' ],
+       '902' => [ 'b', 'c' ],
+       '903' => [ 'a', 'b', 'c' ],
+       '904' => [ 'a' ],
+       '905' => [ 'a*' ],
 }, 'simple rules parsed');
 
-ok($v = new WebPAC::Validate(
-       debug => $debug,
-), "new witout path");
+diag dump( $v ) if ( $debug );
 
-ok( ! $v->{rules}, 'no path' );
+ok( $v->read_validate_file( "$abs_path/data/validate_test_simple" ), "read_validate_file" );
 
-ok( $v->read_validate_file( "$abs_path/data/validate_test" ), "read_validate_file" );
+diag dump( $v ) if ( $debug );
 
 ok($v->{rules}, "rules exist");
 
+is_deeply( $v->{rules}, {
+       '900' => [ 'a', 'b', 'c', 'd' ],
+}, 'rules parsed');
+
+ok( $v->read_validate_file( "$abs_path/data/validate_test" ), "read_validate_file" );
+
 is_deeply( $v->{rules}, {
        '900' => 1,
        '901' => [ 'a' ],
@@ -45,8 +60,9 @@ is_deeply( $v->{rules}, {
        '903' => [ 'a', 'b', 'c' ],
        '904' => [ 'a' ],
        '905' => [ 'a*' ],
-}, 'rules parsed');
+}, 'rules');
 
+ok($v->{rules}, "rules exist");
 
 throws_ok { $v->validate_rec() } qr/rec/, "validate_rec need rec";
 
@@ -173,6 +189,8 @@ $expected_error, 'validate without subfields');
 
 ok(my $r1 = $v->report, 'report');
 
+diag "report: $r1" if ( $debug );
+
 is_deeply(
        test_v({
                '900' => 'foo',
@@ -184,7 +202,6 @@ is_deeply(
        }, undef),
 $expected_error, 'validate with subfields');
 
-
 ok(my $r2 = $v->report, 'report');
 
 cmp_ok($r1, 'eq', $r2, 'subfields same as non-subfields');