4 # See "Writing a test" in perlhack.pod for the instructions about the order that
5 # testing directories run, and which constructions should be avoided in the
8 # This regression tests ensures that the rules aren't accidentally overlooked.
17 open my $fh, '<', '../MANIFEST' or die "Can't open MANIFEST: $!";
19 # Three tests in t/comp need to use require or use to get their job done:
20 my %exceptions = (hints => "require './test.pl'",
21 parser => 'use DieDieDie',
22 proto => 'use strict',
25 while (my $file = <$fh>) {
26 next unless $file =~ s!^t/!!;
29 next unless $file =~ m!\.t$!;
32 open my $t, '<', $file or die "Can't open $file: $!";
34 # Make sure that we don't match ourselves
35 unlike($contents, qr/use\s+Test::More/, "$file doesn't use Test::\QMore");
36 next unless $file =~ m!^base/! or $file =~ m!^comp!;
38 # Remove only the excepted constructions for the specific files.
39 if ($file =~ m!comp/(.*)\.t! && $exceptions{$1}) {
40 my $allowed = $exceptions{$1};
41 $contents =~ s/\Q$allowed//gs;
44 # All uses of use are allowed in t/comp/use.t
45 unlike($contents, qr/^\s*use\s+/m, "$file doesn't use use")
46 unless $file eq 'comp/use.t';
47 # All uses of require are allowed in t/comp/require.t
48 unlike($contents, qr/^\s*require\s+/m, "$file doesn't use require")
49 unless $file eq 'comp/require.t'
52 # There are regression tests using test.pl that don't want PL_sawampersand
53 # set. Or at least that was the case until PL_sawampersand was disabled
54 # and replaced with copy-on-write.
56 # We still allow PL_sawampersand to be enabled with
57 # -Accflags=-DPERL_SAWAMPERSAND, so when that is defined we can still run
58 # these tests. When it is not enabled, PL_sawampersand makes no observable
59 # difference so the tests fail.
62 exit unless "@{[Config::bincompat_options()]}" =~ /\bPERL_SAWAMPERSAND\b/;
64 # This very much relies on a bug in the regexp implementation, but for now it's
65 # the best way to work out whether PL_sawampersand is true.
66 # Then again, PL_sawampersand *is* a bug, for precisely the reason that this
67 # test can detect the behaviour change.
69 isnt($INC{'./test.pl'}, undef, 'We loaded test.pl');
70 ok("Perl rules" =~ /Perl/, 'Perl rules');
71 is(eval '$&', undef, 'Nothing in test.pl mentioned $&');
72 is(eval '$`', undef, 'Nothing in test.pl mentioned $`');
73 is(eval '$\'', undef, 'Nothing in test.pl mentioned $\'');
74 # Currently seeing any of the 3 triggers the setting of all 3.
75 # $` and $' will be '' rather than undef if the regexp sets them.