X-Git-Url: http://erislabs.net/gitweb/?p=liburi-template-perl.git;a=blobdiff_plain;f=t%2F10-basic.t;h=4d6f404c8ddcf8d812dbb7149d26a1d6e408109b;hp=934d87da031c1959021f5f9a4f8b3a57ac3f6ff5;hb=1d94fcb2781945132b9a29e93744b6c168e647aa;hpb=5ea1ac36de0445293009b06d3a28620e63f92916 diff --git a/t/10-basic.t b/t/10-basic.t index 934d87d..4d6f404 100644 --- a/t/10-basic.t +++ b/t/10-basic.t @@ -1,14 +1,37 @@ use strict; use warnings; -use Test::More tests => 15; +use Test::More tests => 21; use_ok( 'URI::Template' ); -# fatal - no template provided +# new, empty template { - eval { URI::Template->new; }; - ok( $@ ); + my $template = URI::Template->new; + isa_ok( $template, 'URI::Template' ); + + { + my $result = $template->process(); + is( $result, '', 'process() for empty template' ); + isa_ok( $result, 'URI', 'return value from process() isa URI' ); + } +} + +# Update template +{ + my $template = URI::Template->new; + is( "$template", '', 'stringify from empty' ); + + my $text = 'http://foo.com/{bar}/{baz}'; + $template->template($text); + + is( "$template", $text, 'stringify from updated template' ); + + { + my $result = $template->process( bar => 'x', baz => 'y' ); + is( $result, 'http://foo.com/x/y', 'process() for updated template' ); + isa_ok( $result, 'URI', 'return value from process() isa URI' ); + } } {