From 25d10ece4ef65863fa4e47f8239c737db9b72c98 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sat, 4 Apr 2015 09:09:55 -0700 Subject: 1015 --- cpp/tangle/030tangle.cc | 22 +--------------------- cpp/tangle/030tangle.test.cc | 37 ------------------------------------- 2 files changed, 1 insertion(+), 58 deletions(-) (limited to 'cpp/tangle') diff --git a/cpp/tangle/030tangle.cc b/cpp/tangle/030tangle.cc index ec34c944..2f81b23f 100644 --- a/cpp/tangle/030tangle.cc +++ b/cpp/tangle/030tangle.cc @@ -203,10 +203,7 @@ list::iterator balancing_curly(list::iterator orig) { void emit_test(const string& name, list& lines, list& result) { result.push_back("TEST("+name+")"); while (any_non_input_line(lines)) { - if (!any_line_starts_with(lines, "=>")) - emit_session(lines, result); // simpler version; no need to check result - else - emit_result_checking_session(lines, result); + result.push_back(" "+Toplevel+"(\""+input_lines(lines)+"\");"); if (!lines.empty() && lines.front()[0] == '+') result.push_back(" CHECK_TRACE_CONTENTS(\""+expected_in_trace(lines)+"\");"); while (!lines.empty() && lines.front()[0] == '-') { @@ -233,23 +230,6 @@ void emit_test(const string& name, list& lines, list& result) { } } -void emit_session(list& lines, list& result) { - result.push_back(" "+Toplevel+"(\""+input_lines(lines)+"\");"); -} - -void emit_result_checking_session(list& lines, list& result) { - result.push_back("{"); - result.push_back(" ostringstream os;"); - result.push_back(" TEMP(tmp, "+Toplevel+"(\""+input_lines(lines)+"\"));"); - result.push_back(" os << tmp;"); - if (!lines.empty() && starts_with(lines.front(), "=>")) { - size_t pos = lines.front().find("=>")+2; // length of '=>' - result.push_back(" CHECK_EQ(os.str(), \""+trim(string(lines.front(), pos))+"\");"); - lines.pop_front(); - } - result.push_back("}"); -} - bool is_input(const string& line) { return line != "===" && line[0] != '+' && line[0] != '-' && !starts_with(line, "=>"); } diff --git a/cpp/tangle/030tangle.test.cc b/cpp/tangle/030tangle.test.cc index eb468894..950123f2 100644 --- a/cpp/tangle/030tangle.test.cc +++ b/cpp/tangle/030tangle.test.cc @@ -189,43 +189,6 @@ void test_tangle_can_check_for_absence_at_end_of_scenarios2() { CHECK(lines.empty()); } -void test_tangle_can_check_return_values_of_scenarios() { - istringstream in(":(scenario does_bar)\nabc def\n=> pqr"); - list lines; - tangle(in, lines); - CHECK_EQ(lines.front(), "TEST(does_bar)"); lines.pop_front(); - CHECK_EQ(lines.front(), "{"); lines.pop_front(); - CHECK_EQ(lines.front(), " ostringstream os;"); lines.pop_front(); - CHECK_EQ(lines.front(), " TEMP(tmp, run(\"abc def\\n\"));"); lines.pop_front(); - CHECK_EQ(lines.front(), " os << tmp;"); lines.pop_front(); - CHECK_EQ(lines.front(), " CHECK_EQ(os.str(), \"pqr\");"); lines.pop_front(); - CHECK_EQ(lines.front(), "}"); lines.pop_front(); - CHECK_EQ(lines.front(), "}"); lines.pop_front(); - CHECK(lines.empty()); -} - -void test_tangle_can_check_return_values_of_multiple_scenarios() { - istringstream in(":(scenario does_bar)\nabc\n=> pqr\n+layer1: pqr\ndef\n=> xyz\n"); - list lines; - tangle(in, lines); - CHECK_EQ(lines.front(), "TEST(does_bar)"); lines.pop_front(); - CHECK_EQ(lines.front(), "{"); lines.pop_front(); - CHECK_EQ(lines.front(), " ostringstream os;"); lines.pop_front(); - CHECK_EQ(lines.front(), " TEMP(tmp, run(\"abc\\n\"));"); lines.pop_front(); - CHECK_EQ(lines.front(), " os << tmp;"); lines.pop_front(); - CHECK_EQ(lines.front(), " CHECK_EQ(os.str(), \"pqr\");"); lines.pop_front(); - CHECK_EQ(lines.front(), "}"); lines.pop_front(); - CHECK_EQ(lines.front(), " CHECK_TRACE_CONTENTS(\"layer1: pqr\");"); lines.pop_front(); - CHECK_EQ(lines.front(), "{"); lines.pop_front(); - CHECK_EQ(lines.front(), " ostringstream os;"); lines.pop_front(); - CHECK_EQ(lines.front(), " TEMP(tmp, run(\"def\\n\"));"); lines.pop_front(); - CHECK_EQ(lines.front(), " os << tmp;"); lines.pop_front(); - CHECK_EQ(lines.front(), " CHECK_EQ(os.str(), \"xyz\");"); lines.pop_front(); - CHECK_EQ(lines.front(), "}"); lines.pop_front(); - CHECK_EQ(lines.front(), "}"); lines.pop_front(); - CHECK(lines.empty()); -} - void test_trim() { -- cgit 1.4.1-2-gfad0