summaryrefslogtreecommitdiff
path: root/lib/Test/Harness/t/premature-bailout.t
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2007-12-19 18:18:04 +0000
committerNicholas Clark <nick@ccl4.org>2007-12-19 18:18:04 +0000
commitb965d173aab5196552f8fc4ba42e0913bbdb8d25 (patch)
tree9bd0cffb4752e50e638eb7d58e2c752d4f7fbd15 /lib/Test/Harness/t/premature-bailout.t
parent794f4697121b50d7447d6309d7c9ada4bca913e2 (diff)
downloadperl-b965d173aab5196552f8fc4ba42e0913bbdb8d25.tar.gz
Upgrade to Test::Harness 3.05
Add test boilerplate to various test files. Add FIXME skips for various tests that don't play nicely with the altered layout in the core. lib/Test/Harness/t/unicode.t appears to fail under UTF-8 locales and so will need fixing. p4raw-id: //depot/perl@32659
Diffstat (limited to 'lib/Test/Harness/t/premature-bailout.t')
-rw-r--r--lib/Test/Harness/t/premature-bailout.t124
1 files changed, 124 insertions, 0 deletions
diff --git a/lib/Test/Harness/t/premature-bailout.t b/lib/Test/Harness/t/premature-bailout.t
new file mode 100644
index 0000000000..d38e6d189a
--- /dev/null
+++ b/lib/Test/Harness/t/premature-bailout.t
@@ -0,0 +1,124 @@
+#!/usr/bin/perl -wT
+
+use strict;
+use lib 't/lib';
+
+use Test::More tests => 14;
+
+use TAP::Parser;
+use TAP::Parser::Iterator;
+
+sub tap_to_lines {
+ my $string = shift;
+ my @lines = ( $string =~ /.*\n/g );
+ return \@lines;
+}
+
+my $tap = <<'END_TAP';
+1..4
+ok 1 - input file opened
+... this is junk
+not ok first line of the input valid # todo some data
+# this is a comment
+ok 3 - read the rest of the file
+not ok 4 - this is a real failure
+Bail out! We ran out of foobar.
+not ok 5
+END_TAP
+
+my $parser = TAP::Parser->new(
+ { stream => TAP::Parser::Iterator->new( tap_to_lines($tap) ),
+ }
+);
+
+# results() is sane?
+
+# check the test plan
+my $result = $parser->next();
+
+# TEST
+ok $result->is_plan, 'We should have a plan';
+
+# a normal, passing test
+
+my $test = $parser->next();
+
+# TEST
+ok $test->is_test, '... and a test';
+
+# junk lines should be preserved
+
+my $unknown = $parser->next();
+
+# TEST
+ok $unknown->is_unknown, '... and an unknown line';
+
+# a failing test, which also happens to have a directive
+
+my $failed = $parser->next();
+
+# TEST
+ok $failed->is_test, '... and another test';
+
+# comments
+
+my $comment = $parser->next();
+
+# TEST
+ok $comment->is_comment, '... and a comment';
+
+# another normal, passing test
+
+$test = $parser->next();
+
+# TEST
+ok $test->is_test, '... and another test';
+
+# a failing test
+
+$failed = $parser->next();
+
+# TEST
+ok $failed->is_test, '... and yet another test';
+
+# ok 5 # skip we have no description
+# skipped test
+my $bailout = $parser->next();
+
+# TEST
+ok $bailout->is_bailout, 'And finally we should have a bailout';
+
+# TEST
+is $bailout->as_string, 'We ran out of foobar.',
+ '... and as_string() should return the explanation';
+
+# TEST
+is( $bailout->raw, 'Bail out! We ran out of foobar.',
+ '... and raw() should return the explanation'
+);
+
+# TEST
+is( $bailout->explanation, 'We ran out of foobar.',
+ '... and it should have the correct explanation'
+);
+
+my $more_tap = "1..1\nok 1 - input file opened\n";
+
+my $second_parser = TAP::Parser->new(
+ { stream => TAP::Parser::Iterator->new( [ split( /\n/, $more_tap ) ] ),
+ }
+);
+
+$result = $second_parser->next();
+
+# TEST
+ok $result->is_plan(), "Result is not the leftover line";
+
+$result = $second_parser->next();
+
+# TEST
+ok $result->is_test(), "Result is a test";
+
+# TEST
+ok $result->is_ok(), "The event has passed";
+