]> git.vpit.fr Git - perl/modules/indirect.git/blobdiff - t/20-good.t
Partially revert 502e3aac.
[perl/modules/indirect.git] / t / 20-good.t
index e04ee9d34c04c0a253e2d1e0e3b35f938e437249..d57de4f0cc009fe71835634ebbfa3f1790c410ff 100644 (file)
@@ -9,7 +9,7 @@ package main;
 use strict;
 use warnings;
 
-use Test::More tests => 101 * 8;
+use Test::More tests => 112 * 8 + 10;
 
 BEGIN { delete $ENV{PERL_INDIRECT_PM_DISABLE} }
 
@@ -71,6 +71,98 @@ SKIP:
  }
 }
 
+# These tests must be run outside of eval to be meaningful.
+{
+ sub Zlott::Owww::new { }
+
+ my (@warns, $hook, $desc, $id);
+ BEGIN {
+  $hook = sub { push @warns, indirect::msg(@_) };
+  $desc = "test sort and line endings %d: no indirect construct";
+  $id   = 1;
+ }
+
+ BEGIN { @warns = () }
+ {
+  no indirect hook => $hook;
+  my @stuff = sort Zlott::Owww
+          ->new;
+ }
+ BEGIN { is_deeply \@warns, [ ], sprintf $desc, $id++ }
+
+ BEGIN { @warns = () }
+ {
+  no indirect hook => $hook;
+  my @stuff = sort Zlott::Owww
+               ->new;
+ };
+ BEGIN { is_deeply \@warns, [ ], sprintf $desc, $id++ }
+
+ BEGIN { @warns = () }
+ {
+  no indirect hook => $hook;
+  my @stuff = sort Zlott::Owww
+                 ->new;
+ }
+ BEGIN { is_deeply \@warns, [ ], sprintf $desc, $id++ }
+
+ BEGIN { @warns = () }
+ {
+  no indirect hook => $hook;
+  my @stuff = sort Zlott::Owww
+                  ->new;
+ }
+ BEGIN { is_deeply \@warns, [ ], sprintf $desc, $id++ }
+
+ BEGIN { @warns = () }
+ {
+  no indirect hook => $hook;
+  my @stuff = sort Zlott::Owww
+                   ->new;
+ }
+ BEGIN { is_deeply \@warns, [ ], sprintf $desc, $id++ }
+
+ BEGIN { @warns = () }
+ {
+  no indirect hook => $hook;
+  my @stuff = sort Zlott::Owww
+                     ->new;
+ }
+ BEGIN { is_deeply \@warns, [ ], sprintf $desc, $id++ }
+
+ BEGIN { @warns = () }
+ {
+  no indirect hook => $hook;
+  my @stuff = sort Zlott::Owww
+                       ->new;
+ }
+ BEGIN { is_deeply \@warns, [ ], sprintf $desc, $id++ }
+
+ BEGIN { @warns = () }
+ {
+  no indirect hook => $hook;
+  my @stuff = sort Zlott::Owww
+                          ->new;
+ }
+ BEGIN { is_deeply \@warns, [ ], sprintf $desc, $id++ }
+
+ BEGIN { @warns = () }
+ {
+  no indirect hook => $hook;
+  my @stuff = sort Zlott::Owww
+                            ->new;
+ }
+ BEGIN { is_deeply \@warns, [ ], sprintf $desc, $id++ }
+
+ BEGIN { @warns = () }
+ {
+  no indirect hook => $hook;
+  my @stuff = sort Zlott::Owww
+                             ->new;
+ }
+ BEGIN { is_deeply \@warns, [ ], sprintf $desc, $id++ }
+}
+
 __DATA__
 
 $obj = Hlagh->new;
@@ -310,3 +402,42 @@ zap { 1; };
 zap { 1; 1; };
 ####
 zap { zap { }; 1; };
+####
+my @stuff = sort Hlagh
+     ->new;
+####
+my @stuff = sort Hlagh
+              ->new;
+####
+my @stuff = sort Hlagh
+               ->new;
+####
+my @stuff = sort Hlagh
+                ->new;
+####
+my @stuff = sort Hlagh
+                 ->new;
+####
+my @stuff = sort Hlagh
+                   ->new;
+####
+my @stuff = sort Hlagh
+                     ->new;
+####
+my @stuff = sort Hlagh
+                        ->new;
+####
+sub {
+ my $self = shift;
+ return $self->new ? $self : undef;
+}
+####
+sub {
+ my $self = shift;
+ return $self ? $self->new : undef;
+}
+####
+sub {
+ my $self = shift;
+ return $_[0] ? undef : $self->new;
+}