better utf8 test records
[webpac2] / t / 1-validate-delimiters.t
index 1a663a4..96b6b9e 100755 (executable)
@@ -1,30 +1,24 @@
 #!/usr/bin/perl -w
 
 use strict;
-use Test::More tests => 13;
-use Test::Exception;
 use blib;
 
-use Data::Dump qw/dump/;
-use Cwd qw/abs_path/;
+use Test::More tests => 15;
+
 use File::Temp qw/ :POSIX /;
 
 BEGIN {
+use_ok( 'WebPAC::Test' );
 use_ok( 'WebPAC::Validate' );
 }
 
-my $debug = shift @ARGV;
-
-ok(my $abs_path = abs_path($0), "abs_path");
-$abs_path =~ s#/[^/]*$#/#;
-
 my $delimiters_path = tmpnam();
 
 ok(my $v = new WebPAC::Validate(
        path => "$abs_path/data/validate_test",
        delimiters => [ ' : ', ' ; ', ' / ', ' \. ', ' = ' ],
        delimiters_path => $delimiters_path,
-       debug => $debug,
+       %LOG,
 ), "new");
 
 diag "rules = ", dump( $v->{rules} ) if ( $debug );
@@ -68,12 +62,17 @@ is_deeply( $v->{_delimiters_templates}, {
        901 => { "^a :  / ^b" => 2 },
 }, 'just subfields and delimiters');
 
-ok(my $dt = $v->delimiters_templates, 'delimiters_template');
+ok(! $v->delimiters_templates, 'no accumulated delimiters_template');
+
+ok(my $dt = $v->delimiters_templates( current_input => 1 ), 'delimiters_template');
 diag $dt if ( $debug );
 
-ok($dt = $v->delimiters_templates( report => 1 ), 'delimiters_template report');
+ok($dt = $v->delimiters_templates( report => 1, current_input => 1 ), 'delimiters_template report');
 diag $dt if ( $debug );
 
+$v->reset;
+ok( $v->delimiters_templates, 'have accumulated delimiters_templates');
+
 $v->{_validate_delimiters_templates} = {
        900 => { '^a : ^b' => 1 },
 };
@@ -107,4 +106,4 @@ ok(my $v2 = new WebPAC::Validate(
 
 is_deeply( $v->{_accumulated_delimiters_templates}, $v2->{_validate_delimiters_templates}, 'save/load ok');
 
-diag dump( $v, $v2 ) if ( $debug );
+diag dump( $v, $v2 ) if $debug;