]> git.vpit.fr Git - perl/modules/Sub-Op.git/blobdiff - t/11-existing.t
Handle existing constant subs
[perl/modules/Sub-Op.git] / t / 11-existing.t
index c45a71b464ca7e9dabd24ff59271964f4bb48094..749fff136fa63311fd3925a2032b383dc6b2dd6a 100644 (file)
@@ -5,7 +5,7 @@ use warnings;
 
 use blib 't/Sub-Op-LexicalSub';
 
-use Test::More tests => 2 *((4 + 2 * 4) + (2 * 5) + 1);
+use Test::More tests => 2 * ((1 + 2) * 4 + (1 + 1) * 5) + (2 + 2) + 4;
 
 our $call_foo;
 sub foo { ok $call_foo, 'the preexistent foo was called' }
@@ -13,6 +13,8 @@ sub foo { ok $call_foo, 'the preexistent foo was called' }
 our $call_bar;
 sub bar () { ok $call_bar, 'the preexistent bar was called' }
 
+sub X () { 1 }
+
 our $called;
 
 {
@@ -74,6 +76,9 @@ our $called;
 
 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";
+ok Sub::Op::_constant_sub(do { no strict "refs"; \&{"main::X"} }),
+                                  'X is still a constant';
 
 __DATA__
 foo();
@@ -161,3 +166,7 @@ my $bar = \&bar;
 &$bar;
 ----
 bar # () #
+####
+is X, 2, 'constant overriding';
+----
+X # 2 # [ ]