]> git.vpit.fr Git - perl/modules/Sub-Op.git/blobdiff - t/10-base.t
Split the "custom op" part away
[perl/modules/Sub-Op.git] / t / 10-base.t
index c1760c104e47e477750cb8b9db294868715a2435..a69a7ae1761542a23ec3df3654c6cb7fa91c79f1 100644 (file)
@@ -5,13 +5,16 @@ use warnings;
 
 use blib 't/Sub-Op-LexicalSub';
 
-use Test::More tests => 2 * 15 + 3 * 2 + 2 * 28;
+use Test::More tests => (1 + 3) * 17 + (1 + 2 * 3) * 2 + 2 * 31;
 
 our $called;
 
 {
  local $/ = "####\n";
  while (<DATA>) {
+  chomp;
+  s/\s*$//;
+
   my ($code, $params)           = split /----\s*/, $_;
   my ($names, $ret, $exp, $seq) = split /\s*#\s*/, $params;
 
@@ -51,7 +54,9 @@ our $called;
    $test .= <<"   CHECK_VIVID"
     BEGIN {
      no warnings 'uninitialized'; # Test::Builder can't get the file name
-     is *main::${name}\{CODE\}, undef, '$name: no symbol table vivification';
+     ok !exists &main::${name},  '$name: not stubbed';
+     ok !defined &main::${name}, '$name: body not defined';
+     is *main::${name}\{CODE\}, undef, '$name: empty symbol table entry';
     }
    CHECK_VIVID
   }
@@ -66,7 +71,7 @@ our $called;
 
   is $called, $calls, "@names: the hook was called the right number of times";
   if ($called < $calls) {
-   fail for $called + 1 .. $calls;
+   fail, fail for $called + 1 .. $calls;
   }
  }
 }
@@ -123,6 +128,16 @@ fetch 1, do { no strict 'refs'; *{__PACKAGE__.'::fetch'}{CODE} }, 2
 ----
 fetch # () # [ 1, undef, 2 ]
 ####
+my ($cb, $err);
+BEGIN {
+ $cb = do { no strict 'refs'; \&{__PACKAGE__.'::cvref'} };
+ eval { $cb->() };
+ $err = $@ =~ /^Undefined subroutine &main::cvref/ ? undef : $@;
+}
+cvref $err;
+----
+cvref # () # [ undef ]
+####
 our $scalr = 1;
 scalr $scalr;
 ----
@@ -146,3 +161,9 @@ foo, bar # () # [ 1 ], [ 2 ] # foo, bar
 foo 1, foo(2), 3, bar(4, foo(bar, 5), 6);
 ----
 foo, bar # @_ # [ 2 ], [ ], [ 5 ], [ 4, 5, 6 ], [ 1, 2, 3, 4, 5, 6 ] # foo, bar, foo, bar, foo
+####
+foo 0, sub {
+ foo $_[0], 2, $_[1]
+}->(1, 3), 4;
+----
+foo # @_ # [ 1, 2, 3 ], [ 0, 1, 2, 3, 4 ]