Commit | Line | Data |
c0ebfc1e |
1 | use strict; |
2 | use warnings; |
3 | use Test::More tests => 14; |
4 | |
5 | use Devel::Declare 'method' => sub {}; |
13edc71b |
6 | use File::Spec; |
c0ebfc1e |
7 | |
8 | sub test_eval; |
9 | |
13edc71b |
10 | QUOTE: { |
11 | test_eval 'qq/method/'; |
12 | test_eval 'q/method/'; |
13 | test_eval "'method'"; |
14 | test_eval '"method"'; |
15 | test_eval 'qw/method/'; |
16 | test_eval '<<method; |
c0ebfc1e |
17 | tum ti tum |
18 | method'; |
13edc71b |
19 | } |
20 | |
21 | SYSTEM: { |
22 | test_eval 'sub {`method`}'; # compiled to prevent calling arbitrary exe! |
23 | test_eval 'sub { qx{method} }'; |
24 | } |
25 | |
26 | REGEX: { |
27 | local $_=''; # the passing results will act on $_ |
28 | test_eval 'qr/method/'; |
29 | test_eval '/method/'; |
30 | test_eval 's/method//'; |
31 | test_eval 'tr/method/METHOD/'; |
32 | } |
33 | |
34 | FILE: { |
35 | test_eval q{ no warnings 'reserved'; open method, '<', File::Spec->devnull }; |
36 | test_eval '<method>'; |
37 | } |
c0ebfc1e |
38 | |
39 | sub test_eval { |
40 | my $what = shift; |
41 | eval $what; |
42 | ok !$@, "$what" or d($@); |
43 | } |
44 | { |
45 | my %seen; |
46 | sub d { # diag the error the first time we get it |
47 | my $err = shift; |
48 | $err =~s/ at .*$//; |
49 | $seen{$err}++ or diag $err; |
50 | } |
51 | } |