### ----------------------------------------------------
### -- Template::Nest::XS
### -- Licenses: ISC
### -- Authors: 
### -- File: t/06-badparams.rakutest
### ----------------------------------------------------
use Test;

plan 2;

#use lib '../lib';

use Template::Nest::XS;




my $nest = Template::Nest::XS.new(
	 template_dir => $*PROGRAM.parent.add('tests').Str,
    template_ext => '.html',
    name_label => 'NAME',
    token_delims => ['<!--%','%-->'],
    defaults_namespace_char => '',
    die_on_bad_params => True
);


my $table = {
    NAME => 'table',
    rows => [{
        NAME => 'tr',
        cols => {
            NAME => 'tr',
            bad_param => 'stuff'
        }
    },{
        NAME => 'tr',
        cols => {
            NAME => 'td',
            #no contents
        }
    }]
};


try { $nest.render( $table ) };

like( $!, rx/bad_param.*?does \s not \s exist/, "die on bad params" );

$nest.die_on_bad_params = False;

my $x_html = "<table><tr><tr></tr></tr><tr><td></td></tr></table>";
my $html = $nest.render( $table );
$html ~~ s:g/\s*//;

is( $html, $x_html, "ignores bad param with die_on_bad_params = 0" );


