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