From b6e33d0222cff567d49aa034900bb5c1db209886 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 15 Sep 2016 13:09:39 -0700 Subject: 3363 - bugfix in tangle --- tangle/003tangle.cc | 2 +- tangle/003tangle.test.cc | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/tangle/003tangle.cc b/tangle/003tangle.cc index 276cad67..c01cdb60 100644 --- a/tangle/003tangle.cc +++ b/tangle/003tangle.cc @@ -335,7 +335,7 @@ void emit_test(const string& name, list& lines, list& result) { bool is_input(const string& line) { if (line.empty()) return true; - return line != "===" && line.at(0) != '+' && line.at(0) != '-' && line.at(0) != '$' && line.at(0) != '?'; + return line != "===" && line.find_first_of("+-$?%") != 0; } Line input_lines(list& hunk) { diff --git a/tangle/003tangle.test.cc b/tangle/003tangle.test.cc index 45e1f110..4a28a622 100644 --- a/tangle/003tangle.test.cc +++ b/tangle/003tangle.test.cc @@ -232,6 +232,17 @@ void test_tangle_can_include_c_code_at_end_of_scenario() { CHECK(lines.empty()); } +void test_tangle_can_include_c_code_at_end_of_scenario_without_trace_expectations() { + istringstream in(":(scenario does_bar)\nabc def\n% int x = 1;"); + list lines; + tangle(in, lines); + CHECK_EQ(lines.front().contents, "void test_does_bar() {"); lines.pop_front(); + CHECK_EQ(lines.front().contents, " run(\"abc def\\n\");"); lines.pop_front(); + CHECK_EQ(lines.front().contents, " int x = 1;"); lines.pop_front(); + CHECK_EQ(lines.front().contents, "}"); lines.pop_front(); + CHECK(lines.empty()); +} + void test_tangle_supports_strings_in_scenarios() { istringstream in(":(scenario does_bar)\nabc \"def\"\n+layer1: pqr\n+layer2: \"xyz\""); list lines; -- cgit 1.4.1-2-gfad0