]> git.vpit.fr Git - perl/modules/indirect.git/blob - 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
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   local $SIG{__WARN__} = sub { die 'warn:' . join(' ', @_) };
21   {
22    use indirect;
23    eval "die qq{ok\\n}; $_";
24   }
25   is($@, "ok\n", "use indirect: $_");
26   {
27    no indirect;
28    eval "die qq{ok\n}; $_";
29   }
30   is($@, "ok\n", "no indirect: $_");
31   s/Hlagh/Dongs/g;
32   {
33    use indirect;
34    eval "die qq{ok\\n}; $_";
35   }
36   is($@, "ok\n", "use indirect, defined: $_");
37   {
38    no indirect;
39    eval "die qq{the code compiled but it shouldn't have\n}; $_";
40   }
41   like($@, qr/^warn:Indirect\s+call\s+of\s+method\s+"meh"\s+on\s+object\s+"Dongs"/, "no indirect, defined: $_");
42  }
43 }
44
45 __DATA__
46 meh Hlagh->new;
47 ####
48 meh Hlagh->new();
49 ####
50 meh Hlagh->new, "Wut";