Imported upstream version 0.10
[liburi-template-perl.git] / t / 11-ordered.t
1 use strict;
2 use warnings;
3
4 use Test::More tests => 9;
5
6 use_ok( 'URI::Template' );
7
8 {
9     my $text     = 'http://foo.com/{arg2}/{arg1}';
10     my $template = URI::Template->new( $text );
11     isa_ok( $template, 'URI::Template' );
12     is_deeply(
13         [ $template->all_variables ],
14         [ qw( arg2 arg1 ) ],
15         'all_variables()'
16     );
17
18     {
19         my $result = $template->process( [ qw( x y ) ] );
20         is( $result, 'http://foo.com/x/y', 'process(\@args)' );
21         isa_ok( $result, 'URI', 'return value from process() isa URI' );
22     }
23
24     {
25         my $result = $template->process_to_string( [ qw( x y ) ] );
26         is( $result, 'http://foo.com/x/y', 'process_to_string(\@args)' );
27         ok( !ref $result, 'result is not a ref' );
28     }
29
30     # test for 0 as value
31     {
32         my $result = $template->process_to_string( [ qw( 0 0 ) ] );
33         is( $result, 'http://foo.com/0/0', 'process w/ 0' );
34     }
35
36     # test with no values
37     {
38         my $result = $template->process_to_string( [] );
39         is( $result, 'http://foo.com//', 'process w/ no values' );
40     }
41 }
42