diff options
Diffstat (limited to 'gnu/usr.bin/perl/lib/Test/Simple/t/no_plan.t')
-rw-r--r-- | gnu/usr.bin/perl/lib/Test/Simple/t/no_plan.t | 78 |
1 files changed, 22 insertions, 56 deletions
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/no_plan.t b/gnu/usr.bin/perl/lib/Test/Simple/t/no_plan.t index c0af2d4647e..10e85abda9d 100644 --- a/gnu/usr.bin/perl/lib/Test/Simple/t/no_plan.t +++ b/gnu/usr.bin/perl/lib/Test/Simple/t/no_plan.t @@ -1,3 +1,6 @@ +#!/usr/bin/perl -w +# $Id$ + BEGIN { if( $ENV{PERL_CORE} ) { chdir 't'; @@ -8,66 +11,29 @@ BEGIN { } } -# Can't use Test.pm, that's a 5.005 thing. -package My::Test; - -print "1..12\n"; - -my $test_num = 1; -# Utility testing functions. -sub ok ($;$) { - my($test, $name) = @_; - my $ok = ''; - $ok .= "not " unless $test; - $ok .= "ok $test_num"; - $ok .= " - $name" if defined $name; - $ok .= "\n"; - print $ok; - $test_num++; -} - - -package main; - -require Test::Simple; - -require Test::Simple::Catch; -my($out, $err) = Test::Simple::Catch::caught(); - -eval { - Test::Simple->import; -}; - -My::Test::ok($$out eq ''); -My::Test::ok($$err eq ''); -My::Test::ok($@ eq ''); - -eval { - Test::Simple->import(tests => undef); -}; - -My::Test::ok($$out eq ''); -My::Test::ok($$err eq ''); -My::Test::ok($@ =~ /Got an undefined number of tests/); +use Test::More tests => 9; -eval { - Test::Simple->import(tests => 0); -}; +my $tb = Test::Builder->create; +$tb->level(0); -My::Test::ok($$out eq ''); -My::Test::ok($$err eq ''); -My::Test::ok($@ =~ /You said to run 0 tests!/); +#line 20 +ok !eval { $tb->plan(tests => undef) }; +is($@, "Got an undefined number of tests at $0 line 20.\n"); -eval { - Test::Simple::ok(1); -}; -My::Test::ok( $@ =~ /You tried to run a test without a plan!/); +#line 24 +ok !eval { $tb->plan(tests => 0) }; +is($@, "You said to run 0 tests at $0 line 24.\n"); +#line 28 +ok !eval { $tb->ok(1) }; +is( $@, "You tried to run a test without a plan at $0 line 28.\n"); -END { - My::Test::ok($$out eq ''); - My::Test::ok($$err eq ""); +{ + my $warning = ''; + local $SIG{__WARN__} = sub { $warning .= join '', @_ }; - # Prevent Test::Simple from exiting with non zero. - exit 0; +#line 36 + ok $tb->plan(no_plan => 1); + is( $warning, "no_plan takes no arguments at $0 line 36.\n" ); + is $tb->has_plan, 'no_plan'; } |