]> git.vpit.fr Git - perl/modules/Sub-Op.git/blobdiff - t/11-existing.t
Update VPIT::TestHelpers to 15e8aee3
[perl/modules/Sub-Op.git] / t / 11-existing.t
index 6c2e9ba75664d61c3ce226eefbf8c8010cf97872..ed74f5843fed94627de7a18e9fa2169358d92f53 100644 (file)
@@ -5,7 +5,7 @@ use warnings;
 
 use blib 't/Sub-Op-LexicalSub';
 
-use Test::More tests => 2 * ((2 + 2) * 4 + (1 + 2) * 5) + 2 * (2 + 2) + 4;
+use Test::More tests => 2 * ((2 + 2) * 4 + (1 + 2) * 5) + 2 * (2 + 2) + 4 + 4;
 
 our $call_foo;
 sub foo { ok $call_foo, 'the preexistent foo was called' }
@@ -18,6 +18,9 @@ sub X () { 1 }
 our $call_blech;
 sub blech { ok $call_blech, 'initial blech was called' };
 
+our $wat_args;
+sub wat { is_deeply \@_, $wat_args, 'wat was called with the right arguments' }
+
 our $called;
 
 {
@@ -62,7 +65,7 @@ our $called;
   }
   $test .= "{\n$code\n}\n";
   $test .= "}\n";
-  for my $name (grep +{ map +($_, 1), qw/foo bar blech/ }->{ $_ }, @names) {
+  for my $name (grep +{ map +($_, 1), qw<foo bar blech> }->{ $_ }, @names) {
    $test .= <<"   CHECK_SUB"
     {
      local \$call_$name = 1;
@@ -86,6 +89,21 @@ our $called;
  }
 }
 
+{
+ eval <<' TEST';
+  use Sub::Op::LexicalSub what => \&wat;
+  local $wat_args = [ 1 ];
+  what 1;
+  local $wat_args = [ 2, 3 ];
+  what 2, 3;
+  local $wat_args = [ 4, 5 ];
+  sub {
+   what $_[0], 5;
+  }->(4);
+ TEST
+ is $@, '', 'what: no errors';
+}
+
 is prototype('main::foo'), undef, "foo's prototype was preserved";
 is prototype('main::bar'), '',    "bar's prototype was preserved";
 is prototype('main::X'),   '',    "X's prototype was preserved";