8 # Utility testing functions.
11 my($test, $name) = @_;
12 print "not " unless $test;
14 print " - $name" if (defined $name && ! $^O eq 'VMS');
21 BEGIN { $| = 1; $^W = 1; }
22 END {print "not ok $test_num\n" unless $loaded;}
23 print "1..$Total_tests\n";
30 # Methods which Exporter says it implements.
31 @Exporter_Methods = qw(import
38 BEGIN { $Total_tests = 14 + @Exporter_Methods }
44 # Make sure Testing can do everything its supposed to.
45 foreach my $meth (@::Exporter_Methods) {
46 ::ok( Testing->can($meth), "subclass can $meth()" );
50 This => [qw(stuff %left)],
51 That => [qw(Above the @wailing)],
52 tray => [qw(Fasten $seatbelt)],
54 @EXPORT = qw(lifejacket);
55 @EXPORT_OK = qw(under &your $seat);
58 ::ok( Testing->require_version(1.05), 'require_version()' );
59 eval { Testing->require_version(1.11); 1 };
60 ::ok( $@, 'require_version() fail' );
61 ::ok( Testing->require_version(0), 'require_version(0)' );
63 sub lifejacket { 'lifejacket' }
67 sub Fasten { 'Fasten' }
70 use vars qw($seatbelt $seat @wailing %left);
71 $seatbelt = 'seatbelt';
73 @wailing = qw(AHHHHHH);
74 %left = ( left => "right" );
77 Exporter::export_ok_tags;
79 my %tags = map { $_ => 1 } map { @$_ } values %EXPORT_TAGS;
80 my %exportok = map { $_ => 1 } @EXPORT_OK;
82 foreach my $tag (keys %tags) {
83 $ok = exists $exportok{$tag};
85 ::ok( $ok, 'export_ok_tags()' );
91 ::ok( defined &lifejacket, 'simple import' );
95 my @imports = qw($seatbelt &Above stuff @wailing %left);
96 Testing->import(@imports);
98 ::ok( (!grep { eval "!defined $_" } map({ /^\w/ ? "&$_" : $_ } @imports)),
99 'import by symbols' );
103 my @tags = qw(:This :tray);
104 Testing->import(@tags);
106 ::ok( (!grep { eval "!defined $_" } map { /^\w/ ? "&$_" : $_ }
107 map { @$_ } @{$Testing::EXPORT_TAGS{@tags}}),
112 Testing->import(qw(!lifejacket));
114 ::ok( !defined &lifejacket, 'deny import by !' );
118 Testing->import('/e/');
120 ::ok( (!grep { eval "!defined $_" } map { /^\w/ ? "&$_" : $_ }
121 grep { /e/ } @Testing::EXPORT, @Testing::EXPORT_OK),
126 Testing->import('!/e/');
128 ::ok( (!grep { eval "defined $_" } map { /^\w/ ? "&$_" : $_ }
129 grep { /e/ } @Testing::EXPORT, @Testing::EXPORT_OK),
130 'deny import by regex');
131 ::ok( !defined &lifejacket, 'further denial' );
134 package More::Testing;
137 eval { More::Testing->require_version(0); 1 };
138 ::ok(!$@, 'require_version(0) and $VERSION = 0');
141 package Yet::More::Testing;
144 eval { Yet::More::Testing->require_version(10); 1 };
145 ::ok($@ !~ /\(undef\)/, 'require_version(10) and $VERSION = 0');