diff options
-rw-r--r-- | cpp/tangle/030tangle.cc | 5 | ||||
-rw-r--r-- | cpp/tangle/030tangle.test.cc | 11 |
2 files changed, 16 insertions, 0 deletions
diff --git a/cpp/tangle/030tangle.cc b/cpp/tangle/030tangle.cc index 944b12ef..33ff6e28 100644 --- a/cpp/tangle/030tangle.cc +++ b/cpp/tangle/030tangle.cc @@ -119,6 +119,11 @@ void process_next_hunk(istream& in, const string& directive, const string& filen ++line_number; continue; } + if (cmd == "scenario" && trim(curr_line).empty()) { + // ignore empty lines in scenarios + ++line_number; + continue; + } hunk.push_back(Line(curr_line, filename, line_number)); ++line_number; } diff --git a/cpp/tangle/030tangle.test.cc b/cpp/tangle/030tangle.test.cc index 9ea0353d..c811881d 100644 --- a/cpp/tangle/030tangle.test.cc +++ b/cpp/tangle/030tangle.test.cc @@ -177,6 +177,17 @@ void test_tangle_supports_scenarios() { CHECK(lines.empty()); } +void test_tangle_ignores_empty_lines_in_scenarios() { + istringstream in(":(scenario does_bar)\nabc def\n+layer1: pqr\n \n+layer2: xyz"); + list<Line> lines; + tangle(in, lines); + CHECK_EQ(lines.front().contents, "TEST(does_bar)"); lines.pop_front(); + CHECK_EQ(lines.front().contents, " run(\"abc def\\n\");"); lines.pop_front(); + CHECK_EQ(lines.front().contents, " CHECK_TRACE_CONTENTS(\"layer1: pqrlayer2: xyz\");"); lines.pop_front(); + CHECK_EQ(lines.front().contents, "}"); lines.pop_front(); + CHECK(lines.empty()); +} + void test_tangle_handles_empty_lines_in_scenarios() { istringstream in(":(scenario does_bar)\nabc def\n\n+layer1: pqr\n+layer2: xyz"); list<Line> lines; |