xref: /openbsd-src/gnu/usr.bin/perl/t/run/switchM.t (revision 3d61058aa5c692477b6d18acfbbdb653a9930ff9)
1#!./perl
2
3BEGIN {
4    chdir 't' if -d 't';
5    @INC = '../lib';
6    require Config;
7    Config->import;
8
9}
10use strict;
11
12require './test.pl';
13
14plan(5);
15
16like(runperl(switches => ['-Irun/flib', '-Mbroken'], stderr => 1),
17     qr/^Global symbol "\$x" requires explicit package name \(did you (?x:
18        )forget to declare "my \$x"\?\) at run\/flib\/broken.pm line 6\./,
19     "Ensure -Irun/flib produces correct filename in warnings");
20
21like(runperl(switches => ['-Irun/flib/', '-Mbroken'], stderr => 1),
22     qr/^Global symbol "\$x" requires explicit package name \(did you (?x:
23        )forget to declare "my \$x"\?\) at run\/flib\/broken.pm line 6\./,
24     "Ensure -Irun/flib/ produces correct filename in warnings");
25
26like(runperl(switches => ['-Irun/flib/', '-M', 'broken'], stderr => 1),
27     qr/^Global symbol "\$x" requires explicit package name \(did you (?x:
28        )forget to declare "my \$x"\?\) at run\/flib\/broken.pm line 6\./,
29     "Ensure -Irun/flib/ produces correct filename in warnings with space after -M");
30
31SKIP: {
32    my $no_pmc;
33    foreach(Config::non_bincompat_options()) {
34	if($_ eq "PERL_DISABLE_PMC"){
35	    $no_pmc = 1;
36	    last;
37	}
38    }
39
40    if ( $no_pmc ) {
41        skip('Tests fail without PMC support', 2);
42    }
43
44    like(runperl(switches => ['-Irun/flib', '-Mt2'], prog => 'print t2::id()', stderr => 1),
45         qr/^t2pmc$/,
46         "Ensure -Irun/flib loads pmc");
47
48    like(runperl(switches => ['-Irun/flib/', '-Mt2'], prog => 'print t2::id()', stderr => 1),
49         qr/^t2pmc$/,
50         "Ensure -Irun/flib/ loads pmc");
51}
52