From 3414569db2d48c7b10168214ac46c93921584f5d Mon Sep 17 00:00:00 2001 From: Luka Vandervelden Date: Mon, 23 Nov 2020 23:09:20 +0100 Subject: [PATCH] Ignores comment lines. --- src/tap.cr | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/tap.cr b/src/tap.cr index e540b3d..af9bb6c 100644 --- a/src/tap.cr +++ b/src/tap.cr @@ -35,12 +35,16 @@ module Tap tap : Tap::Suite? = nil text.lines.each do |line| - md = line.match(/^([0-9]+)\.\.([0-9]+)$/) - if md + if md = line.match /^[ \t]*#.*$/ + # Comments, currently ignored. + next + end + + if md = line.match(/^([0-9]+)\.\.([0-9]+)$/) unless tap tap = Tap::Suite.new md[2].to_i else - if (tap.size+1) != md[2].to_i + if tap.size != md[2].to_i raise ParserError.new "Number of tests parsed does not match number of tests written in suite." end end @@ -48,8 +52,7 @@ module Tap next end - md = line.match(/^(not ok|ok) ([0-9]+) *- *([^#]*)(#.*)?$/) - if md + if md = line.match(/^(not ok|ok) ([0-9]+) *- *([^#]*)(#.*)?$/) unless tap tap = Tap::Suite.new end