[Bps-public-commit] Path-Dispatcher branch, named_captures, updated. 30732149c791602827b1bc0c7fce863e72bb2cbc
Shawn Moore
sartak at bestpractical.com
Thu Jun 24 17:24:33 EDT 2010
The branch, named_captures has been updated
via 30732149c791602827b1bc0c7fce863e72bb2cbc (commit)
from ba63bd5e50c74dae50f871b63e9975bebd725225 (commit)
Summary of changes:
lib/Path/Dispatcher/Match.pm | 10 ++++++++--
t/903-number-vars.t | 5 +----
2 files changed, 9 insertions(+), 6 deletions(-)
- Log -----------------------------------------------------------------
commit 30732149c791602827b1bc0c7fce863e72bb2cbc
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Thu Jun 24 17:25:31 2010 -0400
Fix for stomping on capture variables
rjbs++ abigail++
diff --git a/lib/Path/Dispatcher/Match.pm b/lib/Path/Dispatcher/Match.pm
index c0920b9..cfb0fd5 100644
--- a/lib/Path/Dispatcher/Match.pm
+++ b/lib/Path/Dispatcher/Match.pm
@@ -55,12 +55,18 @@ sub _run_with_capture_vars {
# it'd be nice if we could use "local" but it seems to break tests
my $i = 0;
no strict 'refs';
- *{ ++$i } = \$_ for @{ $self->positional_captures };
# populate %+
*+ = $self->named_captures;
- $code->();
+ my $assignments = join "\n",
+ map { "local *$_ = \\(\$self->positional_captures->[$_-1]);" }
+ 1 .. @{ $self->positional_captures };
+
+ eval "
+ $assignments;
+ \$code->();
+ ";
}
__PACKAGE__->meta->make_immutable;
diff --git a/t/903-number-vars.t b/t/903-number-vars.t
index f08791e..9ed3893 100644
--- a/t/903-number-vars.t
+++ b/t/903-number-vars.t
@@ -31,8 +31,5 @@ $dispatch->run;
is_deeply([splice @vars], [['bus', 'train', undef]]);
-TODO: {
- local $TODO = "we stomp on number vars..";
- is_deeply([$1, $2, $3, $4], ["a", "b", "c", undef]);
-};
+is_deeply([$1, $2, $3, $4], ["a", "b", "c", undef]);
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list