Permalink
Browse files

Add tests for junk_line handling that would have failed before

  • Loading branch information...
1 parent 4c4bfe2 commit ca1c0baaba5c89c9b4a71786232695df26782a49 @arodland committed Aug 2, 2011
Showing with 44 additions and 0 deletions.
  1. +44 −0 t/junk-behavior.t
View
@@ -0,0 +1,44 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+use TAP::Spec::Parser;
+use Test::More;
+
+my $result = eval {
+ TAP::Spec::Parser->parse_from_string(
+ <<EOTAP
+1..3
+ok 1
+ok 2
+1..1
+ok 3
+EOTAP
+ );
+};
+
+my $error = $@;
+ok !$result, "No parse for invalid TAP";
+like $error, qr/Expected/, "Parse error for invalid TAP";
+
+$result = eval {
+ TAP::Spec::Parser->parse_from_string(
+ <<EOTAP
+1..3
+ok 1
+ok 2
+this is junk
+ok 3
+EOTAP
+ );
+};
+
+$error = $@;
+ok $result, "Got parse for valid TAP with junk";
+ok !$error, "No parse error for valid TAP with junk";
+ok $result->passed, "Valid TAP passed tests";
+is $result->plan->number_of_tests, 3, "Planned 3 tests";
+my @tests = $result->tests;
+is scalar @tests, 3, "Found 3 tests";
+
+done_testing;

0 comments on commit ca1c0ba

Please sign in to comment.