diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2001-09-06 03:49:13 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2001-09-06 03:49:13 +0000 |
commit | 9ebf09bc35992a0eeace2e06916ca4dca399c8f2 (patch) | |
tree | 9723dff3340d04a55253c81aa1784eed3b0fba1c | |
parent | 8d9b0165fb4dd847d2330fb27e0c353a472fb897 (diff) | |
download | perl-9ebf09bc35992a0eeace2e06916ca4dca399c8f2.tar.gz |
More tests.
p4raw-id: //depot/perl@11909
-rw-r--r-- | lib/Exporter.t | 47 |
1 files changed, 31 insertions, 16 deletions
diff --git a/lib/Exporter.t b/lib/Exporter.t index a0028feb23..f2771db3f5 100644 --- a/lib/Exporter.t +++ b/lib/Exporter.t @@ -5,25 +5,25 @@ BEGIN { @INC = '../lib'; } -# Utility testing functions. -my $test_num = 1; +# Can't use Test::Simple/More, they depend on Exporter. +my $test = 1; sub ok ($;$) { - my($test, $name) = @_; - print "not " unless $test; - print "ok $test_num"; - print " - $name" if (defined $name && ! $^O eq 'VMS'); - print "\n"; - $test_num++; + my($ok, $name) = @_; + + # You have to do it this way or VMS will get confused. + printf "%sok %d%s\n", ($ok ? '' : 'not '), $test, + (defined $name ? " - $name" : ''); + + printf "# Failed test at line %d\n", (caller)[2] unless $ok; + + $test++; + return $ok; } -my $loaded; -BEGIN { $| = 1; $^W = 1; } -END {print "not ok $test_num\n" unless $loaded;} -print "1..$Total_tests\n"; -use Exporter; -$loaded = 1; -ok(1, 'compile'); +print "1..19\n"; +require Exporter; +ok( 1, 'Exporter compiled' ); BEGIN { @@ -35,7 +35,6 @@ BEGIN { ); } -BEGIN { $Total_tests = 14 + @Exporter_Methods } package Testing; require Exporter; @@ -143,3 +142,19 @@ package Yet::More::Testing; $VERSION = 0; eval { Yet::More::Testing->require_version(10); 1 }; ::ok($@ !~ /\(undef\)/, 'require_version(10) and $VERSION = 0'); + + +my $warnings; +BEGIN { + $SIG{__WARN__} = sub { $warnings = join '', @_ }; + package Testing::Unused::Vars; + @ISA = qw(Exporter); + @EXPORT = qw(this $TODO that); + + package Foo; + Testing::Unused::Vars->import; +} + +::ok( !$warnings, 'Unused variables can be exported without warning' ) || + print "# $warnings\n"; + |