disabled code for B::OP arguments, not finished (no api yet)
[p5sagit/Devel-BeginLift.git] / t / generate.t
index d732e4f..e6cd89f 100644 (file)
@@ -2,18 +2,43 @@ use strict;
 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 { 
+sub foo {
     B::SVOP->new("const", 0, 42);
 }
 
-use Devel::BeginLift qw(foo);
+sub gorch ($) {
+    my $meth = ( $_[0]->kids )[-1]->sv->object_2svref;
+    $$meth = "other";
+    $_[0];
+}
 
-sub bar { 7 + 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");
+