
##  ReDIF perl suite test script:
##     ReDIF::init.pm
## 
##
##

my $test_file = "t/1995.rdf";

BEGIN {print "1..8\n";}
END {print "not ok 1\n" unless $loaded;}

### BEGIN { $::RR_BUG_FIX = 1; }
### use rr BUG_FIX;

BEGIN { 
#	push @ARGV, '--spec' , './spec/redif.spec'; 
}

use rr ('BUG_FIX');

$redif_spec_filename = $ReDIF::CONFIG{spec_full_name}; 
print "redif.spec: $redif_spec_filename\n";

$loaded = 1;

print "ok 1\n";

if ( not $rr::BUG_FIXED ) {
    print "not ok 2\n";
} else {
    print "ok 2\n";
}

my $t = rr::OpenRDF ( $test_file ) ;
if ( not $t ) {
    print "not ok 3\n";
    exit;
} 
  
print "ok 3\n";

$t = rr::NextTemplate();

# if ( not ref $HashT{'template-type'} ) { die; }
# if ( not scalar( @{$HashT{'template-type'}} ) == 1 ) { die; }

$t = rr::NextTemplate();

# if ( not ref $HashT{'template-type'} ) { die; }
# if ( not scalar( @{$HashT{'template-type'}} ) == 1 ) { die; }

### $t = rr::NextTemplate();
$t = rr::NextTemplate();

if ( not ref $HashT{'template-type'} ) { undef $t; }
if ( scalar( @{$HashT{'template-type'}} ) != 1 ) { undef $t; }

if ($t) {
    print "ok 4\n";
} else {
    print "not ok 4\n";
}      

if ( ref ($HashT{title}) eq 'ARRAY'  
   and not ref( $HashT{title}[0] ) ) { 
   print "ok 5\n";
} else {
   print "not ok 5 ", ref( $HashT{title}[0] ), "\n";
}

# print "Handle: ", join ( " | " , @{$HashT{handle}} ), "\n";


if ( $HashT{'handle'}[0] eq 'RePEc:cre:uqamwp:9510' ) {
    print "ok 6\n";
} else {
    print "not ok 6\n";
    print "6: Handle is " , $HashT{handle}[0] , "\n";
}

# if ( scalar( @{$HashT{'template-type'}} ) > 1 ) {
#    die "double template-type";
# }
# print "ok 7\n";

if ( not ref $HashT{'template-type'} ) {
    print "not ok 7\n";
} else {
    print "ok 7\n";
}


# if ( $HashT{file}[0]{format}[0] eq 'text/plain' ) {
if ( $HashT{file}[0]{format}[0] eq 'application/pdf' ) {
    print "ok 8\n";
} else {
    print "not ok 8\n";
#    print $HashT{file}[0]{format}  "\n"; 
}





__END__


BEGIN { push @INC, "/home/ivan/devel/validator"; }

use pretty_print;
pretty_print ( \%::HashT );





