diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2001-06-25 13:35:41 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2001-06-25 13:35:41 +0000 |
commit | 4dd974daccefd178b570ef862ae9d655a6d519cc (patch) | |
tree | f5248b7aca8e9a0f1a337f827450ae55996e7566 /t/lib | |
parent | 1bce926b4bfd587cbea768960be5294d58c0426b (diff) | |
download | perl-4dd974daccefd178b570ef862ae9d655a6d519cc.tar.gz |
Add Test::Simple from Michael G Schwern.
p4raw-id: //depot/perl@10913
Diffstat (limited to 't/lib')
-rw-r--r-- | t/lib/Test/Simple/Catch.pm | 29 | ||||
-rw-r--r-- | t/lib/Test/Simple/sample_tests/death.plx | 13 | ||||
-rw-r--r-- | t/lib/Test/Simple/sample_tests/death_in_eval.plx | 22 | ||||
-rw-r--r-- | t/lib/Test/Simple/sample_tests/extras.plx | 16 | ||||
-rw-r--r-- | t/lib/Test/Simple/sample_tests/five_fail.plx | 13 | ||||
-rw-r--r-- | t/lib/Test/Simple/sample_tests/last_minute_death.plx | 16 | ||||
-rw-r--r-- | t/lib/Test/Simple/sample_tests/one_fail.plx | 14 | ||||
-rw-r--r-- | t/lib/Test/Simple/sample_tests/require.plx | 1 | ||||
-rw-r--r-- | t/lib/Test/Simple/sample_tests/success.plx | 13 | ||||
-rw-r--r-- | t/lib/Test/Simple/sample_tests/too_few.plx | 11 | ||||
-rw-r--r-- | t/lib/Test/Simple/sample_tests/two_fail.plx | 14 |
11 files changed, 162 insertions, 0 deletions
diff --git a/t/lib/Test/Simple/Catch.pm b/t/lib/Test/Simple/Catch.pm new file mode 100644 index 0000000000..2f8c887d49 --- /dev/null +++ b/t/lib/Test/Simple/Catch.pm @@ -0,0 +1,29 @@ +# For testing Test::Simple; +package Catch; + +my $out = tie *Test::Simple::TESTOUT, 'Catch'; +my $err = tie *Test::Simple::TESTERR, 'Catch'; + +# We have to use them to shut up a "used only once" warning. +() = (*Test::Simple::TESTOUT, *Test::Simple::TESTERR); + +sub caught { return $out, $err } + +# Prevent Test::Simple from exiting in its END block. +*Test::Simple::exit = sub {}; + +sub PRINT { + my $self = shift; + $$self .= join '', @_; +} + +sub TIEHANDLE { + my $class = shift; + my $self = ''; + return bless \$self, $class; +} +sub READ {} +sub READLINE {} +sub GETC {} + +1; diff --git a/t/lib/Test/Simple/sample_tests/death.plx b/t/lib/Test/Simple/sample_tests/death.plx new file mode 100644 index 0000000000..8796eb2451 --- /dev/null +++ b/t/lib/Test/Simple/sample_tests/death.plx @@ -0,0 +1,13 @@ +require Test::Simple; + +push @INC, 't', '.'; +require Catch; +my($out, $err) = Catch::caught(); + +Test::Simple->import(tests => 5); +close STDERR; + +ok(1); +ok(1); +ok(1); +die "Knife?"; diff --git a/t/lib/Test/Simple/sample_tests/death_in_eval.plx b/t/lib/Test/Simple/sample_tests/death_in_eval.plx new file mode 100644 index 0000000000..969dbb009a --- /dev/null +++ b/t/lib/Test/Simple/sample_tests/death_in_eval.plx @@ -0,0 +1,22 @@ +require Test::Simple; +use Carp; + +push @INC, 't', '.'; +require Catch; +my($out, $err) = Catch::caught(); + +Test::Simple->import(tests => 5); + +ok(1); +ok(1); +ok(1); +eval { + die "Foo"; +}; +ok(1); +eval "die 'Bar'"; +ok(1); + +eval { + croak "Moo"; +}; diff --git a/t/lib/Test/Simple/sample_tests/extras.plx b/t/lib/Test/Simple/sample_tests/extras.plx new file mode 100644 index 0000000000..ed2d6abbbf --- /dev/null +++ b/t/lib/Test/Simple/sample_tests/extras.plx @@ -0,0 +1,16 @@ +require Test::Simple; + +push @INC, 't', '.'; +require Catch; +my($out, $err) = Catch::caught(); + +Test::Simple->import(tests => 5); + + +ok(1); +ok(1); +ok(1); +ok(1); +ok(0); +ok(1); +ok(0); diff --git a/t/lib/Test/Simple/sample_tests/five_fail.plx b/t/lib/Test/Simple/sample_tests/five_fail.plx new file mode 100644 index 0000000000..c95e4100d5 --- /dev/null +++ b/t/lib/Test/Simple/sample_tests/five_fail.plx @@ -0,0 +1,13 @@ +require Test::Simple; + +push @INC, 't', '.'; +require Catch; +my($out, $err) = Catch::caught(); + +Test::Simple->import(tests => 5); + +ok(0); +ok(0); +ok(''); +ok(0); +ok(0); diff --git a/t/lib/Test/Simple/sample_tests/last_minute_death.plx b/t/lib/Test/Simple/sample_tests/last_minute_death.plx new file mode 100644 index 0000000000..e1df5b1970 --- /dev/null +++ b/t/lib/Test/Simple/sample_tests/last_minute_death.plx @@ -0,0 +1,16 @@ +require Test::Simple; + +push @INC, 't', '.'; +require Catch; +my($out, $err) = Catch::caught(); + +Test::Simple->import(tests => 5); +close STDERR; + +ok(1); +ok(1); +ok(1); +ok(1); +ok(1); + +die "Almost there..."; diff --git a/t/lib/Test/Simple/sample_tests/one_fail.plx b/t/lib/Test/Simple/sample_tests/one_fail.plx new file mode 100644 index 0000000000..1762d65df0 --- /dev/null +++ b/t/lib/Test/Simple/sample_tests/one_fail.plx @@ -0,0 +1,14 @@ +require Test::Simple; + +push @INC, 't', '.'; +require Catch; +my($out, $err) = Catch::caught(); + +Test::Simple->import(tests => 5); + + +ok(1); +ok(2); +ok(0); +ok(1); +ok(2); diff --git a/t/lib/Test/Simple/sample_tests/require.plx b/t/lib/Test/Simple/sample_tests/require.plx new file mode 100644 index 0000000000..1a06690d9d --- /dev/null +++ b/t/lib/Test/Simple/sample_tests/require.plx @@ -0,0 +1 @@ +require Test::Simple; diff --git a/t/lib/Test/Simple/sample_tests/success.plx b/t/lib/Test/Simple/sample_tests/success.plx new file mode 100644 index 0000000000..eb40a2d7d0 --- /dev/null +++ b/t/lib/Test/Simple/sample_tests/success.plx @@ -0,0 +1,13 @@ +require Test::Simple; + +push @INC, 't', '.'; +require Catch; +my($out, $err) = Catch::caught(); + +Test::Simple->import(tests => 5); + +ok(1); +ok(5, 'yep'); +ok(3, 'beer'); +ok("wibble", "wibble"); +ok(1); diff --git a/t/lib/Test/Simple/sample_tests/too_few.plx b/t/lib/Test/Simple/sample_tests/too_few.plx new file mode 100644 index 0000000000..36acac94f6 --- /dev/null +++ b/t/lib/Test/Simple/sample_tests/too_few.plx @@ -0,0 +1,11 @@ +require Test::Simple; + +push @INC, 't', '.'; +require Catch; +my($out, $err) = Catch::caught(); + +Test::Simple->import(tests => 5); + + +ok(1); +ok(0); diff --git a/t/lib/Test/Simple/sample_tests/two_fail.plx b/t/lib/Test/Simple/sample_tests/two_fail.plx new file mode 100644 index 0000000000..5ddb912dec --- /dev/null +++ b/t/lib/Test/Simple/sample_tests/two_fail.plx @@ -0,0 +1,14 @@ +require Test::Simple; + +push @INC, 't', '.'; +require Catch; +my($out, $err) = Catch::caught(); + +Test::Simple->import(tests => 5); + + +ok(0); +ok(1); +ok(1); +ok(0); +ok(1); |