]> git.vpit.fr Git - perl/modules/indirect.git/blob - t/22-bad-mixed.t
3a01f463bbe19124219dac69a05ba0f09e37ad39
[perl/modules/indirect.git] / t / 22-bad-mixed.t
1 #!perl -T
2
3 package Dongs;
4
5 sub new;
6
7 package main;
8
9 use strict;
10 use warnings;
11
12 use Test::More tests => 3 * 4;
13
14 sub meh;
15
16 {
17  local $/ = "####\n";
18  while (<DATA>) {
19   chomp;
20   s/\s*$//;
21
22   local $SIG{__WARN__} = sub { die 'warn:' . join(' ', @_) };
23
24   eval "die qq{ok\\n}; use indirect; $_";
25   is($@, "ok\n", "use indirect: $_");
26
27   eval "die qq{ok\n}; no indirect; $_";
28   is($@, "ok\n", "no indirect: $_");
29
30   s/Hlagh/Dongs/g;
31
32   eval "die qq{ok\\n}; use indirect; $_";
33   is($@, "ok\n", "use indirect, defined: $_");
34
35   eval "die qq{the code compiled but it shouldn't have\n}; no indirect; $_";
36   like($@, qr/^warn:Indirect\s+call\s+of\s+method\s+"meh"\s+on\s+object\s+"Dongs"/, "no indirect, defined: $_");
37  }
38 }
39
40 __DATA__
41 meh Hlagh->new;
42 ####
43 meh Hlagh->new();
44 ####
45 meh Hlagh->new, "Wut";