
### -*- Mode: perl -*-

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

eval " use ReDIF::Parser; ";

test( not( $@ ), $@ );

use ReDIF::Parser qw( &redif_open_file &redif_get_next_template );

my $r;
my $t;

$r = redif_open_file( 't/test.rdf' );

test ( $r ) ;

$t = redif_get_next_template();

test( $t );

test( $t->{'FILENAME'} );


$r = redif_open_file( 't/names_test.rdf' );
$t = redif_get_next_template();

my $authors = $t->{author};

test( scalar( @$authors ) == 2 );

my $h = $t->{handle};

test( (scalar( @$h ) == 1 ) , $h->[0] );

test( $h->[0] );

my $tt = $t->{'template-type'};

test( (scalar( @$tt ) == 1 ) , $tt->[0] );




###############################################################
#############     TESTING   FRAMEWORK     #####################
###############################################################

sub test {
    push @TESTS, shift;
    push @MESSAGES, shift;
}

sub ok { 
    push @TESTS, 1; 
    push @MESSAGES, shift;
}
sub nok { 
    push @TESTS, 0; 
    push @MESSAGES, shift;
}



END { 

    my $tests = scalar @TESTS;

    if( not $tests ) {
	print "1..1\nnot ok 1\n";
	exit;
    }

    print "1..$tests\n";

    my $counter = 1;
    while ( 1 ) {
	my $t = shift @TESTS;
	my $m = shift @MESSAGES;
	if( not $t ) {
	    print "not ";
	}
	print "ok $counter\n";

	if( $m ) { 
	    print "[$counter] $m\n";
	}
	last if not scalar @TESTS;
	$counter ++;
    }
}
