X-Git-Url: http://erislabs.net/gitweb/?p=liburi-template-perl.git;a=blobdiff_plain;f=t%2F10-basic.t;h=42403674cd7c2ae33d59701da2a12ce7072950ab;hp=7dc6308f8eb7393117ebb4a55643ea41b6ffe005;hb=e0de6ab08282e52476e36abb99a35be9eff9ca8e;hpb=90a266f52eaecdd5e15d16fe4fa3b98cb184c67c diff --git a/t/10-basic.t b/t/10-basic.t index 7dc6308..4240367 100644 --- a/t/10-basic.t +++ b/t/10-basic.t @@ -1,7 +1,7 @@ use strict; use warnings; -use Test::More tests => 25; +use Test::More tests => 15; use_ok( 'URI::Template' ); @@ -52,71 +52,6 @@ use_ok( 'URI::Template' ); } } -# test from spec -{ - my %vals = ( - a => 'fred', - b => 'barney', - c => 'cheeseburger', - d => 'one two three', - e => '20% tricky', - f => '', - 20 => 'this-is-spinal-tap', - scheme => 'https', - p => 'quote=to+be+or+not+to+be', - q => 'hullo#world', - ); - - my @urls = ( - [ ( - 'http://example.org/page1#{a}', - 'http://example.org/page1#fred', - ) ], - [ ( - 'http://example.org/{a}/{b}/', - 'http://example.org/fred/barney/', - ) ], - [ ( - 'http://example.org/{a}{b}/', - 'http://example.org/fredbarney/', - ) ], - [ ( - 'http://example.com/order/{c}/{c}/{c}/', - 'http://example.com/order/cheeseburger/cheeseburger/cheeseburger/', - ) ], - [ ( - 'http://example.org/{d}', - 'http://example.org/one%20two%20three', - ) ], - [ ( - 'http://example.org/{e}', - 'http://example.org/20%25%20tricky', - ) ], - [ ( - 'http://example.com/{f}/', - 'http://example.com//', - ) ], - [ ( - '{scheme}://{20}.example.org?date={wilma}&option={a}', - 'https://this-is-spinal-tap.example.org?date=&option=fred', - ) ], - [ ( - 'http://example.org?{p}', - 'http://example.org?quote=to+be+or+not+to+be', - ) ], - [ ( - 'http://example.com/{q}', - 'http://example.com/hullo#world', - ) ], - ); - - for my $list ( @urls ) { - my $template = URI::Template->new( $list->[ 0 ] ); - my $result = $template->process( %vals ); - is( $result, $list->[ 1 ], 'escaped properly' ); - } -} - { my $template = URI::Template->new( 'http://foo.com/{z}/{z}/' ); is_deeply( [ $template->variables ], [ 'z' ], 'unique vars' );