From 6ac0e8f44776b9dea515356fa5270596bcaa25b1 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 28 Nov 2009 12:48:42 -0800 Subject: [PATCH] Remove tapir.pir and move beginning of parse_tapstream() implementation into Tapir::Parser --- lib/Tapir/Parser.pir | 30 +++++++++++++++++++ tapir.pir | 82 ---------------------------------------------------- 2 files changed, 30 insertions(+), 82 deletions(-) delete mode 100644 tapir.pir diff --git a/lib/Tapir/Parser.pir b/lib/Tapir/Parser.pir index 68cc407..062d33c 100644 --- a/lib/Tapir/Parser.pir +++ b/lib/Tapir/Parser.pir @@ -14,6 +14,36 @@ Written and maintained by Jonathan "Duke" Leto C<< jonathan@leto.net >>. # set_hll_global [ 'Tapir'; 'Parser' ], '_parser', parser #.end +.sub parse_tapstream + .param string tap + .local string curr_line, delim + .local int passed, failed, skipped, todoed + .local int i + .local int curr_test + .local pmc tap_lines + .local pmc parts + i = 1 + + tap_lines = new 'ResizablePMCArray' + parts = new 'ResizablePMCArray' + delim = "\n" + split tap_lines, delim, tap + + loop: + curr_line = tap_lines[i] + unless curr_line goto done + delim = "ok " + + split parts, delim, curr_line + curr_test = parts[1] + # check curr_test for comments + inc i + goto loop + + done: + .return (passed,failed,skipped,todoed) +.end + # parse_plan returns the expected number of test given a TAP stream as a string .sub parse_plan :method diff --git a/tapir.pir b/tapir.pir deleted file mode 100644 index 7f7f60c..0000000 --- a/tapir.pir +++ /dev/null @@ -1,82 +0,0 @@ -# Copyright (C) 2009, Jonathan "Duke" Leto - -=head1 AUTHOR - -Written and maintained by Jonathan "Duke" Leto C<< jonathan@leto.net >>. - -=cut - -.sub main :main - .local int num_tests - $S0 = "1..5\nFoobar!" - num_tests = parse_plan($S0) - print "Expected number of tests=" - say num_tests -.end - -.sub parse_tests - .param string tap - .local string curr_line, delim - .local int passed, failed, skipped, todoed - .local int i - .local int curr_test - .local pmc tap_lines - .local pmc parts - i = 1 - - tap_lines = new 'ResizablePMCArray' - parts = new 'ResizablePMCArray' - delim = "\n" - split tap_lines, delim, tap - - loop: - curr_line = tap_lines[i] - unless curr_line goto done - delim = "ok " - - split parts, delim, curr_line - curr_test = parts[1] - # check curr_test for comments - inc i - goto loop - - done: - .return (passed,failed,skipped,todoed) -.end - -.sub parse_plan - .param string tap - .local pmc tap_lines - .local pmc plan_parts - .local int num_expected_tests - .local string delim - .local string plan - - tap_lines = new 'ResizablePMCArray' - delim = "\n" - split tap_lines, delim, tap - plan = tap_lines[0] - print "plan=" - say plan - unless plan goto error - delim = ".." - plan_parts = new 'ResizablePMCArray' - split plan_parts, delim, plan - - unless plan_parts goto plan_error - num_expected_tests = plan_parts[1] - - .return (num_expected_tests) - error: - die 'Invalid TAP Stream, no plan found' - plan_error: - die 'Invalid TAP Plan' -.end - - -# Local Variables: -# mode: pir -# fill-column: 100 -# End: -# vim: expandtab shiftwidth=4 ft=pir: - -- 2.11.4.GIT