Commit | Line | Data |
9a10ba4a |
1 | === t/generate.t |
2 | ================================================================== |
3 | --- t/generate.t (revision 24729) |
4 | +++ t/generate.t (local) |
5 | @@ -2,43 +2,18 @@ |
6 | use warnings; |
7 | use Test::More; |
8 | |
9 | -use B::Utils; |
10 | - |
11 | BEGIN { |
12 | plan skip_all => "B::Generate required" unless eval { require B::Generate }; |
13 | plan 'no_plan'; |
14 | } |
15 | |
16 | -sub foo { |
17 | - B::SVOP->new("const", 0, 42); |
18 | +sub foo { |
19 | + return B::SVOP->new("const", 0, 42); |
20 | } |
21 | |
22 | -sub gorch ($) { |
23 | - my $meth = ( $_[0]->kids )[-1]->sv->object_2svref; |
24 | - $$meth = "other"; |
25 | - $_[0]; |
26 | -} |
27 | +use Devel::BeginLift qw(foo); |
28 | |
29 | -use Devel::BeginLift qw(foo gorch); |
30 | - |
31 | sub bar { 7 + foo() } |
32 | + |
33 | is( bar(), 49, "optree injected" ); |
34 | |
35 | -sub blah { foo(31) } |
36 | -is(blah(), 42, "optree injected" );; |
37 | - |
38 | -sub meth { 3 } |
39 | - |
40 | -sub other { 42 } |
41 | - |
42 | -__END__ |
43 | - |
44 | -my $obj = bless {}; |
45 | -sub oink { gorch $obj->meth; } |
46 | - |
47 | -is( oink(), 42, "modify method call"); |
48 | - |
49 | -my @args = ( 1 .. 3 ); |
50 | -sub ploink { gorch $obj->meth(1, @args); } |
51 | -is( ploink(), 42, "modify method call with args"); |
52 | - |