]> git.vpit.fr Git - perl/modules/Scope-Upper.git/blobdiff - t/32-localize_elem-block.t
Protect against d_cplusplus perls
[perl/modules/Scope-Upper.git] / t / 32-localize_elem-block.t
index 36014bda538d10da224b1468787338c412cd984f..82cabc7ce515fd2419c031a5c7484b7d30a8e0e0 100644 (file)
@@ -3,73 +3,67 @@
 use strict;
 use warnings;
 
-use Test::More 'no_plan'; 
+use lib 't/lib';
+use Test::Leaner 'no_plan';
 
-use Scope::Upper qw/localize_elem/;
+use Scope::Upper qw<localize_elem UP HERE>;
 
-use lib 't/lib';
 use Scope::Upper::TestGenerator;
 
-local $Scope::Upper::TestGenerator::testlocal = sub { '' };
+our $testcase;
 
-local $Scope::Upper::TestGenerator::allblocks = 1;
+local $Scope::Upper::TestGenerator::local_test = sub { '' };
 
-our $testcase;
+local $Scope::Upper::TestGenerator::allblocks = 1;
 
 local $Scope::Upper::TestGenerator::call = sub {
  my ($height, $level, $i) = @_;
+ $level = $level ? 'UP ' x $level : 'HERE';
  return [ "localize_elem '\@a', 1 => 0 => $level;\n" ];
 };
 
 local $Scope::Upper::TestGenerator::test = sub {
  my ($height, $level, $i, $x) = @_;
  my $j = ($i == $height - $level) ? 0 : (defined $x ? $x : 11);
- return "is(\$a[1], $j, 'x h=$height, l=$level, i=$i');\n";
+ return "verbose_is(\$a[1], $j, 'x h=$height, l=$level, i=$i');\n";
 };
 
-local $Scope::Upper::TestGenerator::local = sub {
- my $x = $_[3];
- return "local \$a[1] = $x;\n";
-};
+local $Scope::Upper::TestGenerator::local_var = '$a[1]';
 
 our @a;
 
 for my $level (0 .. 1) {
  my $height = $level + 1;
  my $tests = Scope::Upper::TestGenerator::gen($height, $level);
- for (@$tests) {
-  $testcase = $_;
+ for $testcase (@$tests) {
   @a = (10, 11);
-  eval;
+  eval $testcase;
   diag $@ if $@;
  }
 }
 
 local $Scope::Upper::TestGenerator::call = sub {
  my ($height, $level, $i) = @_;
+ $level = $level ? 'UP ' x $level : 'HERE';
  return [ "localize_elem '%h', 'a' => 0 => $level;\n" ];
 };
 
 local $Scope::Upper::TestGenerator::test = sub {
  my ($height, $level, $i, $x) = @_;
  my $j = ($i == $height - $level) ? 0 : (defined $x ? $x : 'undef');
- return "is(\$h{a}, $j, 'x h=$height, l=$level, i=$i');\n";
+ return "verbose_is(\$h{a}, $j, 'x h=$height, l=$level, i=$i');\n";
 };
 
-local $Scope::Upper::TestGenerator::local = sub {
- my $x = $_[3];
- return "local \$h{a} = $x;\n";
-};
+local $Scope::Upper::TestGenerator::local_var = '$h{a}';
 
 our %h;
 
 for my $level (0 .. 1) {
  my $height = $level + 1;
  my $tests = Scope::Upper::TestGenerator::gen($height, $level);
- for (@$tests) {
-  $testcase = $_;
+ for $testcase (@$tests) {
   %h = ();
-  eval;
+  eval $testcase;
   diag $@ if $@;
  }
 }