From: Dobrica Pavlinusic Date: Sun, 9 Aug 2009 20:10:21 +0000 (+0000) Subject: fix foreach my combination X-Git-Url: http://git.rot13.org/?a=commitdiff_plain;h=87df497b2d849ea5fae2ba1641850af3dc1ba53e;p=webpac2 fix foreach my combination git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@1265 07558da8-63fa-0310-ba24-9fe276d99e06 --- diff --git a/lib/WebPAC/Parser.pm b/lib/WebPAC/Parser.pm index bdd79ce..5d2e72f 100644 --- a/lib/WebPAC/Parser.pm +++ b/lib/WebPAC/Parser.pm @@ -337,6 +337,8 @@ sub _parse_source { # repair demage done by prune of whitespace $Element->insert_after( PPI::Token::Whitespace->new(' ') ); return ''; + } elsif ( $Element->content eq 'my' ) { + $Element->insert_before( PPI::Token::Whitespace->new(' ') ); } $Element->content eq 'lookup' or return ''; diff --git a/t/2-parse.t b/t/2-parse.t index 23687c1..34a795b 100755 --- a/t/2-parse.t +++ b/t/2-parse.t @@ -154,5 +154,5 @@ diag "test = ",dump( @test ) if $debug; ok(! $@, "eval: $@" ); -is_deeply( [ @test ], [ "foo", "foo", "bar >>2<<", "bar >>42<<" ], 'sub executed' ); +is_deeply( [ @test ], [ "foo", "foo", "bar >>2<<", "bar >>42<<", 1,2,3 ], 'source fixed' ); diff --git a/t/conf/normalize/sub.pl b/t/conf/normalize/sub.pl index c810355..62dec98 100644 --- a/t/conf/normalize/sub.pl +++ b/t/conf/normalize/sub.pl @@ -1,3 +1,5 @@ +# check all repairs in WebPAC::Parser + sub foo { push @test, 'foo'; } @@ -9,3 +11,11 @@ sub bar($) { foo(); bar(foo()); bar(42); + +sub test($) { + push @test, $_[0]; +} + +foreach my $a ( 1,2,3 ) { + test($a); +}