]> git.vpit.fr Git - perl/modules/indirect.git/blobdiff - t/22-bad-mixed.t
Test 'package A; sub foo; foo A->new' that gets deparsed as 'A->foo->new'
[perl/modules/indirect.git] / t / 22-bad-mixed.t
diff --git a/t/22-bad-mixed.t b/t/22-bad-mixed.t
new file mode 100644 (file)
index 0000000..bbc2f23
--- /dev/null
@@ -0,0 +1,50 @@
+#!perl -T
+
+package Dongs;
+
+sub new;
+
+package main;
+
+use strict;
+use warnings;
+
+use Test::More tests => 3 * 4;
+
+sub meh;
+
+{
+ local $/ = "####\n";
+ while (<DATA>) {
+  chomp;
+  local $SIG{__WARN__} = sub { die 'warn:' . join(' ', @_) };
+  {
+   use indirect;
+   eval "die qq{ok\\n}; $_";
+  }
+  is($@, "ok\n", "use indirect: $_");
+  {
+   no indirect;
+   eval "die qq{ok\n}; $_";
+  }
+  is($@, "ok\n", "no indirect: $_");
+  s/Hlagh/Dongs/g;
+  {
+   use indirect;
+   eval "die qq{ok\\n}; $_";
+  }
+  is($@, "ok\n", "use indirect, defined: $_");
+  {
+   no indirect;
+   eval "die qq{the code compiled but it shouldn't have\n}; $_";
+  }
+  like($@, qr/^warn:Indirect\s+call\s+of\s+method\s+"meh"\s+on\s+object\s+"Dongs"/, "no indirect, defined: $_");
+ }
+}
+
+__DATA__
+meh Hlagh->new;
+####
+meh Hlagh->new();
+####
+meh Hlagh->new, "Wut";