/[webpac2]/trunk/t/1-validate.t
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/t/1-validate.t

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 849 by dpavlin, Sun May 27 10:50:37 2007 UTC revision 857 by dpavlin, Sun May 27 16:49:15 2007 UTC
# Line 1  Line 1 
1  #!/usr/bin/perl -w  #!/usr/bin/perl -w
2    
3  use strict;  use strict;
4  use Test::More tests => 47;  use Test::More tests => 51;
5  use Test::Exception;  use Test::Exception;
6  use blib;  use blib;
7    
# Line 17  my $debug = shift @ARGV; Line 17  my $debug = shift @ARGV;
17  ok(my $abs_path = abs_path($0), "abs_path");  ok(my $abs_path = abs_path($0), "abs_path");
18  $abs_path =~ s#/[^/]*$#/#;  $abs_path =~ s#/[^/]*$#/#;
19    
20  throws_ok { new WebPAC::Validate( no_log => 1 ) } qr/need path/, "new without path";  my $validate_path = "$abs_path/data/validate_test";
21    $validate_path =~ s#//+#/#g;
22    
23  ok(my $v = new WebPAC::Validate(  ok(my $v = new WebPAC::Validate(
24          path => "$abs_path/data/validate_test",          path => $validate_path,
25          debug => $debug,          debug => $debug,
26  ), "new");  ), "new with path");
27    
28  ok($v->{rules}, "rules exist");  ok($v->{rules}, "rules exist");
29    
# Line 35  is_deeply( $v->{rules}, { Line 36  is_deeply( $v->{rules}, {
36          '905' => [ 'a*' ],          '905' => [ 'a*' ],
37  }, 'rules parsed');  }, 'rules parsed');
38    
39    ok($v = new WebPAC::Validate(
40            debug => $debug,
41    ), "new witout path");
42    
43    ok( ! $v->{rules}, 'no path' );
44    
45    ok( $v->read_validate_file( $validate_path ), "read_validate_file( $validate_path )" );
46    
47    ok($v->{rules}, "rules exist");
48    
49    is_deeply( $v->{rules}, {
50            '900' => 1,
51            '901' => [ 'a' ],
52            '902' => [ 'b', 'c' ],
53            '903' => [ 'a', 'b', 'c' ],
54            '904' => [ 'a' ],
55            '905' => [ 'a*' ],
56    }, 'rules parsed');
57    
58    
59  throws_ok { $v->validate_rec() } qr/rec/, "validate_rec need rec";  throws_ok { $v->validate_rec() } qr/rec/, "validate_rec need rec";

Legend:
Removed from v.849  
changed lines
  Added in v.857

  ViewVC Help
Powered by ViewVC 1.1.26