xref: /openbsd-src/gnu/usr.bin/perl/t/lib/no_load.t (revision 4c1e55dc91edd6e69ccc60ce855900fbc12cf34f)
1#!./perl
2#
3# Check that certain modules don't get loaded when other modules are used.
4#
5
6BEGIN {
7    chdir 't' if -d 't';
8    @INC = qw(. ../lib);
9}
10
11use strict;
12use warnings;
13
14require "test.pl";
15
16#
17# Format: [Module-that-should-not-be-loaded => modules to test]
18#
19my @TESTS = (
20    [Carp  => qw [warnings Exporter]],
21);
22
23my $count = 0;
24$count += @$_ - 1 for @TESTS;
25
26print "1..$count\n";
27
28foreach my $test (@TESTS) {
29    my ($exclude, @modules) = @$test;
30
31    foreach my $module (@modules) {
32        my $prog = <<"        --";
33            use $module;
34            print exists \$INC {'$exclude.pm'} ? "not ok" : "ok";
35        --
36        fresh_perl_is ($prog, "ok", "", "$module does not load $exclude");
37    }
38}
39
40
41__END__
42