X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=t%2F11-ordered.t;fp=t%2F11-ordered.t;h=a16081889ea2cc1ec9f16626c487893641b89427;hb=53a1b94e04453d9c7eea079af549f2179320b952;hp=0000000000000000000000000000000000000000;hpb=7c69490596e221b9d4be4d94de939429258ff7b3;p=liburi-template-perl.git diff --git a/t/11-ordered.t b/t/11-ordered.t new file mode 100644 index 0000000..a160818 --- /dev/null +++ b/t/11-ordered.t @@ -0,0 +1,38 @@ +use strict; +use warnings; + +use Test::More tests => 9; + +use_ok( 'URI::Template' ); + +{ + my $text = 'http://foo.com/{arg2}/{arg1}'; + my $template = URI::Template->new( $text ); + isa_ok( $template, 'URI::Template' ); + is_deeply( [ $template->all_variables ], [ qw( arg2 arg1 ) ], 'all_variables()' ); + + { + my $result = $template->process( [ qw( x y ) ] ); + is( $result, 'http://foo.com/x/y', 'process(\@args)' ); + isa_ok( $result, 'URI', 'return value from process() isa URI' ); + } + + { + my $result = $template->process_to_string( [ qw( x y ) ] ); + is( $result, 'http://foo.com/x/y', 'process_to_string(\@args)' ); + ok( !ref $result, 'result is not a ref' ); + } + + # test for 0 as value + { + my $result = $template->process_to_string( [ qw( 0 0 ) ] ); + is( $result, 'http://foo.com/0/0', 'process w/ 0' ); + } + + # test with no values + { + my $result = $template->process_to_string( [ ] ); + is( $result, 'http://foo.com//', 'process w/ no values' ); + } +} +