disabled code for B::OP arguments, not finished (no api yet)
[p5sagit/Devel-BeginLift.git] / t / generate.t
1 use strict;
2 use warnings;
3 use Test::More;
4
5 use B::Utils;
6
7 BEGIN {
8     plan skip_all => "B::Generate required" unless eval { require B::Generate };
9     plan 'no_plan';
10 }
11
12 sub foo {
13     B::SVOP->new("const", 0, 42);
14 }
15
16 sub gorch ($) {
17     my $meth = ( $_[0]->kids )[-1]->sv->object_2svref;
18     $$meth = "other";
19     $_[0];
20 }
21
22 use Devel::BeginLift qw(foo gorch);
23
24 sub bar { 7 + foo() }
25 is( bar(), 49, "optree injected" );
26
27 sub blah { foo(31) }
28 is(blah(), 42, "optree injected" );;
29
30 sub meth { 3 }
31
32 sub other { 42 }
33
34 __END__
35
36 my $obj = bless {};
37 sub oink { gorch $obj->meth; }
38
39 is( oink(), 42, "modify method call");
40
41 my @args = ( 1 .. 3 );
42 sub ploink { gorch $obj->meth(1, @args); }
43 is( ploink(), 42, "modify method call with args");
44