[svn:parrot] r45818 - in trunk: runtime/parrot/library/TAP t/library
fperrad at svn.parrot.org
fperrad at svn.parrot.org
Tue Apr 20 08:44:07 UTC 2010
Author: fperrad
Date: Tue Apr 20 08:44:06 2010
New Revision: 45818
URL: https://trac.parrot.org/parrot/changeset/45818
Log:
[TAP] fix trailing plan
Modified:
trunk/runtime/parrot/library/TAP/Parser.pir
trunk/t/library/tap_parser.t
Modified: trunk/runtime/parrot/library/TAP/Parser.pir
==============================================================================
--- trunk/runtime/parrot/library/TAP/Parser.pir Tue Apr 20 05:47:08 2010 (r45817)
+++ trunk/runtime/parrot/library/TAP/Parser.pir Tue Apr 20 08:44:06 2010 (r45818)
@@ -162,6 +162,15 @@
.return ($I0)
.end
+.sub 'is_unplanned' :method
+ $I0 = 0
+ $P0 = getattribute self, 'unplanned'
+ if null $P0 goto L1
+ $I0 = $P0
+ L1:
+ .return ($I0)
+.end
+
.namespace ['TAP';'Parser';'Result';'Unknown']
@@ -545,8 +554,6 @@
setattribute self, 'parse_errors', $P0
$P0 = box 0
setattribute self, 'tests_run', $P0
- $P0 = box 0
- setattribute self, 'tests_planned', $P0
$P0 = get_global ['TAP';'Parser'], 'LEGAL_CALLBACK'
setattribute self, 'ok_callbacks', $P0
.end
@@ -938,7 +945,7 @@
st = states['UNPLANNED']
$P0 = st['test']
- $P0['goto'] = 'PLANNED_AFTER_TEST'
+ $P0['goto'] = 'UNPLANNED_AFTER_TEST'
$P0 = st['plan']
$P0['goto'] = 'GOT_PLAN'
@@ -1005,7 +1012,8 @@
.local int tests_planned
tests_planned = $P0
unless tests_run > tests_planned goto L11
- $P0 = box 1
+ $P0 = new 'Boolean'
+ set $P0, 1
setattribute result, 'unplanned', $P0
L11:
Modified: trunk/t/library/tap_parser.t
==============================================================================
--- trunk/t/library/tap_parser.t Tue Apr 20 05:47:08 2010 (r45817)
+++ trunk/t/library/tap_parser.t Tue Apr 20 08:44:06 2010 (r45818)
@@ -21,7 +21,7 @@
load_bytecode 'TAP/Parser.pir'
- plan(179)
+ plan(203)
test_grammar_plan()
test_grammar_bailout()
test_grammar_comment()
@@ -31,6 +31,7 @@
test_tap_with_blank_lines()
test_tap_has_problem()
test_tap_version_wrong_place()
+ test_tap_trailing_plan()
test_aggregator()
.end
@@ -535,6 +536,73 @@
is($S0, "If TAP version is present it must be the first line of output")
.end
+.sub 'test_tap_trailing_plan'
+ .local pmc parser, result, token
+ parser = new ['TAP';'Parser']
+ parser.'tap'(<<'END_TAP')
+ok 1 - input file opened
+ok 2 - Gandalf wins
+1..2
+END_TAP
+ result = _get_results(parser)
+ $I0 = elements result
+ is($I0, 3, "elements")
+
+ token = shift result
+ $P0 = get_class ['TAP';'Parser';'Result';'Test']
+ isa_ok(token, $P0)
+ $P0 = getattribute token, 'ok'
+ is($P0, 'ok', "ok")
+ $P0 = getattribute token, 'test_num'
+ is($P0, 1, "test_num")
+ $P0 = getattribute token, 'description'
+ is($P0, '- input file opened', "description")
+ $I0 = token.'is_ok'()
+ ok($I0)
+ $I0 = token.'is_actual_ok'()
+ ok($I0)
+ $I0 = token.'is_unplanned'()
+ nok($I0, "unplanned")
+
+ token = shift result
+ $P0 = get_class ['TAP';'Parser';'Result';'Test']
+ isa_ok(token, $P0)
+ $P0 = getattribute token, 'ok'
+ is($P0, 'ok', "ok")
+ $P0 = getattribute token, 'test_num'
+ is($P0, 2, "test_num")
+ $P0 = getattribute token, 'description'
+ is($P0, '- Gandalf wins', "description")
+ $I0 = token.'is_ok'()
+ ok($I0)
+ $I0 = token.'is_actual_ok'()
+ ok($I0)
+ $I0 = token.'is_unplanned'()
+ nok($I0, "unplanned")
+
+ token = shift result
+ $P0 = get_class ['TAP';'Parser';'Result';'Plan']
+ isa_ok(token, $P0)
+ $P0 = getattribute token, 'plan'
+ is($P0, "1..2", "plan")
+ $P0 = getattribute token, 'tests_planned'
+ is($P0, 2, "tests_planned")
+
+ $I0 = parser.'passed'()
+ is($I0, 2, "passed")
+ $I0 = parser.'failed'()
+ is($I0, 0, "failed")
+ $I0 = parser.'parse_errors'()
+ is($I0, 0, "parse_errors")
+ $I0 = parser.'has_problems'()
+ is($I0, 0, "has_problems")
+
+ $P0 = getattribute parser, 'plan'
+ is($P0, "1..2", "plan")
+ $P0 = getattribute parser, 'tests_planned'
+ is($P0, 2, "tests_planned")
+.end
+
.sub 'test_aggregator'
.local pmc parser1, parser2, agg
parser1 = new ['TAP';'Parser']
More information about the parrot-commits
mailing list