]> git.vpit.fr Git - perl/modules/indirect.git/blobdiff - t/20-bad.t
Test 'no indirect "hlagh"'
[perl/modules/indirect.git] / t / 20-bad.t
index 05efb509b5698f88cd434b0a6b28e5437b8f6d0d..5c57ebed84a6a2b65e26ee44470402101e460b6b 100644 (file)
@@ -3,9 +3,9 @@
 use strict;
 use warnings;
 
-use Test::More tests => 28 * 2;
+use Test::More tests => 30 * 2 + 2;
 
-my ($obj, $pkg, $cb, $x);
+my ($obj, $x);
 
 {
  local $/ = "####\n";
@@ -26,6 +26,16 @@ my ($obj, $pkg, $cb, $x);
  }
 }
 
+eval {
+ no indirect 'hlagh';
+ my $warn;
+ local $SIG{__WARN__} = sub { $warn = join ' ', @_ };
+ eval "die qq{the code compiled but it shouldn't have\n}; \$obj = new Hlagh1;";
+ like($warn, qr/^Indirect\s+call\s+of\s+method\s+"new"\s+on\s+object\s+"Hlagh1"/, 'no indirect "hlagh" enables the pragma');
+ eval "die qq{the code compiled but it shouldn't have\n}; \$obj = new Hlagh2;";
+ like($warn, qr/^Indirect\s+call\s+of\s+method\s+"new"\s+on\s+object\s+"Hlagh2"/, 'no indirect "hlagh" doesn\'t croak');
+}
+
 __DATA__
 $obj = new Hlagh;
 ####
@@ -95,3 +105,7 @@ $obj = HlaghHlagh Hlagh; # HlaghHlagh Hlagh
 $obj = new newnew;
 ####
 $obj = new newnew; # new newnew
+####
+new Hlagh (meh $x)
+####
+Hlagh->new(meh $x)