]> git.vpit.fr Git - perl/modules/indirect.git/blob - t/22-bad-mixed.t
Only enable the pragma during compile time
[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 $/ = "####";
18  while (<DATA>) {
19   chomp;
20   s/\s*$//;
21   s/(.*?)$//m;
22   my ($skip, $prefix) = split /#+/, $1;
23   $skip   = 0  unless defined $skip;
24   $prefix = '' unless defined $prefix;
25   s/\s*//;
26
27 SKIP:
28   {
29    skip "$_: $skip" => 4 if eval $skip;
30
31    local $SIG{__WARN__} = sub { die 'warn:' . join(' ', @_) };
32
33    eval "die qq{ok\\n}; $prefix; use indirect; $_";
34    is($@, "ok\n", "use indirect: $_");
35
36    eval "die qq{ok\n}; $prefix; no indirect; $_";
37    is($@, "ok\n", "no indirect: $_");
38
39    s/Hlagh/Dongs/g;
40
41    eval "die qq{ok\\n}; $prefix; use indirect; $_";
42    is($@, "ok\n", "use indirect, defined: $_");
43
44    eval "die qq{the code compiled but it shouldn't have\n}; $prefix; no indirect; $_";
45    like($@, qr/^warn:Indirect\s+call\s+of\s+method\s+"meh"\s+on\s+object\s+"Dongs"\s+at\s+\(eval\s+\d+\)\s+line\s+\d+/, "no indirect, defined: $_");
46   }
47  }
48 }
49
50 __DATA__
51
52 meh Hlagh->new;
53 ####
54 meh Hlagh->new();
55 ####
56 meh Hlagh->new, "Wut";