From 9ebf09bc35992a0eeace2e06916ca4dca399c8f2 Mon Sep 17 00:00:00 2001 From: Jarkko Hietaniemi Date: Thu, 6 Sep 2001 03:49:13 +0000 Subject: [PATCH] More tests. p4raw-id: //depot/perl@11909 --- lib/Exporter.t | 47 +++++++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/lib/Exporter.t b/lib/Exporter.t index a0028fe..f2771db 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"; + -- 1.8.3.1