X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=generate.diff;fp=generate.diff;h=0fbd8b3d3d32ef28c9c0a8045d05af21d48f18cb;hb=9a10ba4af97f6e1312b1bb68b7259491a428a335;hp=0000000000000000000000000000000000000000;hpb=62b5f5ed9a05274e0bbc2e76ccdd324a11d91345;p=p5sagit%2FDevel-BeginLift.git diff --git a/generate.diff b/generate.diff new file mode 100644 index 0000000..0fbd8b3 --- /dev/null +++ b/generate.diff @@ -0,0 +1,52 @@ +=== t/generate.t +================================================================== +--- t/generate.t (revision 24729) ++++ t/generate.t (local) +@@ -2,43 +2,18 @@ + use warnings; + use Test::More; + +-use B::Utils; +- + BEGIN { + plan skip_all => "B::Generate required" unless eval { require B::Generate }; + plan 'no_plan'; + } + +-sub foo { +- B::SVOP->new("const", 0, 42); ++sub foo { ++ return B::SVOP->new("const", 0, 42); + } + +-sub gorch ($) { +- my $meth = ( $_[0]->kids )[-1]->sv->object_2svref; +- $$meth = "other"; +- $_[0]; +-} ++use Devel::BeginLift qw(foo); + +-use Devel::BeginLift qw(foo gorch); +- + sub bar { 7 + foo() } ++ + is( bar(), 49, "optree injected" ); + +-sub blah { foo(31) } +-is(blah(), 42, "optree injected" );; +- +-sub meth { 3 } +- +-sub other { 42 } +- +-__END__ +- +-my $obj = bless {}; +-sub oink { gorch $obj->meth; } +- +-is( oink(), 42, "modify method call"); +- +-my @args = ( 1 .. 3 ); +-sub ploink { gorch $obj->meth(1, @args); } +-is( ploink(), 42, "modify method call with args"); +-