Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 8148c00f75
Fetching contributors…

Cannot retrieve contributors at this time

file 47 lines (34 sloc) 1.119 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
use Test::More tests => 8;
use strict;
use warnings;

BEGIN { use_ok('App::Mowyw', 'parse_str'); };

my %meta = ( VARS => {} );

is parse_str('[%setvar foo bar baz %]', \%meta),
        '',
        'setvar returns empty string';

is parse_str('[%readvar foo%]', \%meta),
        'bar baz',
        'readvar returns previous value';

is parse_str('[%setvar a <>&"a%][%readvar a escape:html%]', \%meta),
        '&lt;&gt;&amp;&quot;a',
        'HTML escape';

is parse_str('[%ifvar foo%]bar[%endifvar%]', \%meta),
        'bar',
        'ifvar works on defined variables';

is parse_str('[%ifvar undef%]bar[%readvar argl %][%endifvar%]', \%meta),
        '',
        'ifvar works on undefined variables';

%meta = ( VARS => { foo => { bar => 'baz' } } );

is parse_str('[% readvar foo.bar %]', \%meta),
        'baz',
        'variable access to nested hashes';

$meta{NO_VAR_WARN} = 1;

is parse_str('[% readvar foo.bar.baz %]', \%meta),
        '',
        q{Don't die while accessing non-hash};


#eval {
# parse_str('[% readvar foo bar %]');
#};
#
# TODO:
#ok $@, 'parse error on invalid input';
Something went wrong with that request. Please try again.