Imported upstream version 0.07
[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( [ $template->all_variables ], [ qw( arg2 arg1 ) ], 'all_variables()' );
13
14     {
15         my $result = $template->process( [ qw( x y ) ] );
16         is( $result, 'http://foo.com/x/y', 'process(\@args)' );
17         isa_ok( $result, 'URI', 'return value from process() isa URI' );
18     }
19
20     {
21         my $result = $template->process_to_string( [ qw( x y ) ] );
22         is( $result, 'http://foo.com/x/y', 'process_to_string(\@args)' );
23         ok( !ref $result, 'result is not a ref' );
24     }
25
26     # test for 0 as value
27     {
28         my $result = $template->process_to_string( [ qw( 0 0 ) ] );
29         is( $result, 'http://foo.com/0/0', 'process w/ 0' );
30     }
31
32     # test with no values
33     {
34         my $result = $template->process_to_string( [ ] );
35         is( $result, 'http://foo.com//', 'process w/ no values' );
36     }
37 }
38