--- trunk/t/1-validate.t 2007/05/27 10:50:37 849 +++ trunk/t/1-validate.t 2007/05/27 16:49:15 857 @@ -1,7 +1,7 @@ #!/usr/bin/perl -w use strict; -use Test::More tests => 47; +use Test::More tests => 51; use Test::Exception; use blib; @@ -17,12 +17,13 @@ ok(my $abs_path = abs_path($0), "abs_path"); $abs_path =~ s#/[^/]*$#/#; -throws_ok { new WebPAC::Validate( no_log => 1 ) } qr/need path/, "new without path"; +my $validate_path = "$abs_path/data/validate_test"; +$validate_path =~ s#//+#/#g; ok(my $v = new WebPAC::Validate( - path => "$abs_path/data/validate_test", + path => $validate_path, debug => $debug, -), "new"); +), "new with path"); ok($v->{rules}, "rules exist"); @@ -35,6 +36,24 @@ '905' => [ 'a*' ], }, 'rules parsed'); +ok($v = new WebPAC::Validate( + debug => $debug, +), "new witout path"); + +ok( ! $v->{rules}, 'no path' ); + +ok( $v->read_validate_file( $validate_path ), "read_validate_file( $validate_path )" ); + +ok($v->{rules}, "rules exist"); + +is_deeply( $v->{rules}, { + '900' => 1, + '901' => [ 'a' ], + '902' => [ 'b', 'c' ], + '903' => [ 'a', 'b', 'c' ], + '904' => [ 'a' ], + '905' => [ 'a*' ], +}, 'rules parsed'); throws_ok { $v->validate_rec() } qr/rec/, "validate_rec need rec";