Revision history for Perl extension URI::Template
+0.22 2015-04-04
+ - Fix regression in variables() when called in list context (GH #4)
+
0.21 2015-01-08
- variables() now returns items in their order of appearance (Artem
Krivopolenov)
t/cases/spec-examples-by-section.json
t/cases/spec-examples.json
t/cases/transform-json-tests.xslt
+t/gh-4.t
use strict;
use warnings;
-our $VERSION = '0.21';
+our $VERSION = '0.22';
use URI;
use URI::Escape ();
}
sub variables {
- return sort {$_[ 0 ]->{ _vars }->{ $a } <=> $_[ 0 ]->{ _vars }->{ $b } } keys %{ $_[ 0 ]->{ _vars } };
+ my @vars = sort {$_[ 0 ]->{ _vars }->{ $a } <=> $_[ 0 ]->{ _vars }->{ $b } } keys %{ $_[ 0 ]->{ _vars } };
+ return @vars;
}
sub expansions {
--- /dev/null
+use strict;
+use warnings;
+
+use Test::More tests => 4;
+
+use_ok( 'URI::Template' );
+
+# variables w/ context
+{
+ my $text = 'http://foo.com/{bar}/{baz}?{foo}=%7B&{abr}=1';
+ my $template = URI::Template->new( $text );
+ isa_ok( $template, 'URI::Template' );
+ my @l_vars = $template->variables;
+ is_deeply( \@l_vars, [ 'bar', 'baz', 'foo', 'abr' ], 'variables() in list context' );
+ my $s_vars = $template->variables;
+ is( $s_vars, 4, 'variables() in scalar context' );
+}
+