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