]> git.vpit.fr Git - perl/modules/Sub-Op.git/blobdiff - t/11-existing.t
Handle existing prototyped subs
[perl/modules/Sub-Op.git] / t / 11-existing.t
index 58e23a0a9c02e028f674db046f968171984c5b26..0339bc850b391436f5fe1d7beb6bf97071f58562 100644 (file)
@@ -5,11 +5,14 @@ use warnings;
 
 use blib 't/Sub-Op-LexicalSub';
 
-use Test::More tests => (4 + 2 * 4) + (2 * 5);
+use Test::More tests => 2 *((4 + 2 * 4) + (2 * 5) + 1);
 
 our $call_foo;
 sub foo { ok $call_foo, 'the preexistent foo was called' }
 
+our $call_bar;
+sub bar () { ok $call_bar, 'the preexistent bar was called' }
+
 our $called;
 
 {
@@ -66,6 +69,9 @@ our $called;
  }
 }
 
+is prototype('main::foo'), undef, "foo's prototype was preserved";
+is prototype('main::bar'), '',    "bar's prototype was preserved";
+
 __DATA__
 foo();
 ----
@@ -109,3 +115,46 @@ my $foo = \&foo;
 &$foo;
 ----
 foo # () #
+####
+bar();
+----
+bar # () # [ ]
+####
+bar;
+----
+bar # () # [ ]
+####
+bar(1);
+----
+bar # () # [ 1 ]
+####
+bar 2;
+----
+bar # () # [ 2 ]
+####
+local $call_bar = 1;
+&bar();
+----
+bar # () #
+####
+local $call_bar = 1;
+&bar;
+----
+bar # () #
+####
+local $call_bar = 1;
+&bar(3);
+----
+bar # () #
+####
+local $call_bar = 1;
+my $bar = \&bar;
+$bar->();
+----
+bar # () #
+####
+local $call_bar = 1;
+my $bar = \&bar;
+&$bar;
+----
+bar # () #