/[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 653 by dpavlin, Thu Sep 7 15:57:48 2006 UTC revision 654 by dpavlin, Thu Sep 7 16:41:08 2006 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 => 29;  use Test::More tests => 36;
5  use Test::Exception;  use Test::Exception;
6  use blib;  use blib;
7    
# Line 30  is_deeply( $v->{rules}, { Line 30  is_deeply( $v->{rules}, {
30          '901' => [ 'a' ],          '901' => [ 'a' ],
31          '902' => [ 'b', 'c' ],          '902' => [ 'b', 'c' ],
32          '903' => [ 'a', 'b', 'c' ],          '903' => [ 'a', 'b', 'c' ],
33            '904' => [ 'a' ],
34  }, 'rules parsed');  }, 'rules parsed');
35    
36    
37    
38  throws_ok { $v->validate_errors() } qr/rec/, "validate_rec need rec";  throws_ok { $v->validate_errors() } qr/rec/, "validate_rec need rec";
39    
40  sub test_v {  sub test_v {
# Line 52  sub test_v { Line 55  sub test_v {
55                          my $k = shift @_;                          my $k = shift @_;
56                          ok($tmp = $tmp->{$k}, "found $k");                          ok($tmp = $tmp->{$k}, "found $k");
57                  }                  }
58                  diag "additional message: $tmp" if ($tmp);                  diag "tmp: ",dump($tmp) if ($debug);
59                    if ($tmp) {
60                            if (ref($tmp) eq 'HASH') {
61                                    return $tmp;
62                            } else {
63                                    diag "explanation: $tmp";
64                            }
65                    }
66          } else {          } else {
67                  ok(! $e, "validated $d");                  ok(! $e, "validated $d");
68                  diag "expected error: ", dump($e) if($e);                  diag "expected error: ", dump($e) if($e);
# Line 78  test_v({ Line 88  test_v({
88    
89  test_v({  test_v({
90          '901' => [ { 'b' => 42 } ]          '901' => [ { 'b' => 42 } ]
91  }, qw/field 901 subfield b/);  }, qw/field 901 subfield extra b/);
92    
93  test_v({  test_v({
94          '902' => [ { 'b' => 1 }, { 'c' => 2 } ]          '902' => [ { 'b' => 1 }, { 'c' => 2 } ]
# Line 86  test_v({ Line 96  test_v({
96    
97  test_v({  test_v({
98          '902' => [ { 'a' => 0 }, { 'b' => 1 }, { 'c' => 2 } ]          '902' => [ { 'a' => 0 }, { 'b' => 1 }, { 'c' => 2 } ]
99  }, qw/field 902 subfield a/);  }, qw/field 902 subfield extra a/);
100    
101  test_v({  test_v({
102          '903' => [ { 'a' => 0 }, { 'b' => 1 }, { 'c' => 2 } ]          '903' => [ { 'a' => 0 }, { 'b' => 1 }, { 'c' => 2 } ]
# Line 94  test_v({ Line 104  test_v({
104    
105  test_v({  test_v({
106          '903' => [ { 'a' => 0 }, { 'b' => 1 }, { 'c' => 2 }, { 'd' => 3 } ]          '903' => [ { 'a' => 0 }, { 'b' => 1 }, { 'c' => 2 }, { 'd' => 3 } ]
107  }, qw/field 903 subfield d/);  }, qw/field 903 subfield extra d/);
108    
109    test_v({
110            '903' => [ { 'a' => 0 }, { 'b' => 1 }, { 'c' => 2 }, { 'd' => 3 }, { 'e' => 4 } ]
111    }, qw/field 903 subfield extra/);
112    
113    
114    #test_v({
115    #       '904' => [ { 'b' => 1 } ]
116    #}, qw/field 904 subfield b extra/);

Legend:
Removed from v.653  
changed lines
  Added in v.654

  ViewVC Help
Powered by ViewVC 1.1.26