This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Revamp t/uni/fold.t
[perl5.git] / t / lib / no_load.t
1 #!./perl
2 #
3 # Check that certain modules don't get loaded when other modules are used.
4 #
5
6 BEGIN {
7     chdir 't' if -d 't';
8     @INC = qw(. ../lib);
9 }
10
11 use strict;
12 use warnings;
13
14 require "test.pl";
15
16 #
17 # Format: [Module-that-should-not-be-loaded => modules to test]
18 #
19 my @TESTS = (
20     [Carp  => qw [warnings Exporter]],
21 );
22
23 my $count = 0;
24 $count += @$_ - 1 for @TESTS;
25
26 print "1..$count\n";
27
28 foreach 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__