diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-04-24 22:00:15 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-04-24 22:00:15 -0700 |
commit | 0e82b1d4277e947f19b63331f0a50dec90e0462c (patch) | |
tree | 8fa1df78c71c72ea8d9cd82fa91e100a3ac780b8 | |
parent | 6ca059efce56104efc766255459e665fc7e7705b (diff) | |
download | mu-0e82b1d4277e947f19b63331f0a50dec90e0462c.tar.gz |
1185 - inline C++ in scenarios
-rw-r--r-- | cpp/041name | 2 | ||||
-rw-r--r-- | cpp/050scenario | 2 | ||||
-rw-r--r-- | cpp/tangle/030tangle.cc | 9 | ||||
-rw-r--r-- | cpp/tangle/030tangle.test.cc | 14 | ||||
-rw-r--r-- | cpp/vimrc.vim | 5 |
5 files changed, 9 insertions, 23 deletions
diff --git a/cpp/041name b/cpp/041name index 6afb6b07..20d1222f 100644 --- a/cpp/041name +++ b/cpp/041name @@ -11,7 +11,7 @@ recipe main [ +mem: storing 0 in location 1 :(scenario convert_names_warns) -hide warnings +% Hide_warnings = true; recipe main [ x:integer <- copy y:integer ] diff --git a/cpp/050scenario b/cpp/050scenario index 3bffe992..d8152219 100644 --- a/cpp/050scenario +++ b/cpp/050scenario @@ -62,7 +62,7 @@ scenario foo [ +parse: scenario will run: a <- b :(scenario parse_scenario_memory_expectation_duplicate) -hide warnings +% Hide_warnings = true; scenario foo [ run [ a <- b diff --git a/cpp/tangle/030tangle.cc b/cpp/tangle/030tangle.cc index a7769129..872b4d9d 100644 --- a/cpp/tangle/030tangle.cc +++ b/cpp/tangle/030tangle.cc @@ -283,12 +283,9 @@ void emit_test(const string& name, list<Line>& lines, list<Line>& result) { lines.pop_front(); \ } while (any_non_input_line(lines)) { - if (front(lines).contents == "hide warnings") { - SHIFT(" Hide_warnings = true;"); - } - if (starts_with(front(lines).contents, "dump ")) { - string line = front(lines).contents.substr(strlen("dump ")); - SHIFT(" Trace_stream->dump_layer = \""+line+"\";"); + while (!lines.empty() && starts_with(front(lines).contents, "% ")) { + string line = front(lines).contents.substr(strlen("% ")); + SHIFT(" "+line); } result.push_back(input_lines(lines)); if (!lines.empty() && !front(lines).contents.empty() && front(lines).contents[0] == '+') diff --git a/cpp/tangle/030tangle.test.cc b/cpp/tangle/030tangle.test.cc index 8203b8a6..d97981dc 100644 --- a/cpp/tangle/030tangle.test.cc +++ b/cpp/tangle/030tangle.test.cc @@ -199,7 +199,7 @@ void test_tangle_supports_configurable_toplevel() { } void test_tangle_can_hide_warnings_in_scenarios() { - istringstream in(":(scenario does_bar)\nhide warnings\nabc def\n+layer1: pqr\n+layer2: xyz"); + istringstream in(":(scenario does_bar)\n% Hide_warnings = true;\nabc def\n+layer1: pqr\n+layer2: xyz"); list<Line> lines; tangle(in, lines); CHECK_EQ(lines.front().contents, "TEST(does_bar)"); lines.pop_front(); @@ -210,18 +210,6 @@ void test_tangle_can_hide_warnings_in_scenarios() { CHECK(lines.empty()); } -void test_tangle_can_dump_traces_in_scenarios() { - istringstream in(":(scenario does_bar)\ndump foo\nabc def\n+layer1: pqr\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, " Trace_stream->dump_layer = \"foo\";"); 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_supports_strings_in_scenarios() { istringstream in(":(scenario does_bar)\nabc \"def\"\n+layer1: pqr\n+layer2: \"xyz\""); list<Line> lines; diff --git a/cpp/vimrc.vim b/cpp/vimrc.vim index 382c51fe..944a5fe1 100644 --- a/cpp/vimrc.vim +++ b/cpp/vimrc.vim @@ -11,10 +11,11 @@ function! HighlightTangledFile() syntax region tangleDirective start=+:(+ skip=+".*"+ end=+)+ highlight link tangleDirective Delimiter - syntax region traceContains start="^+" end="$" + syntax match traceContains /^+.*/ highlight traceContains ctermfg=darkgreen - syntax region traceAbsent start="^-" end="$" + syntax match traceAbsent /^-.*/ highlight traceAbsent ctermfg=darkred + syntax match tangleScenarioSetup /^\s*% .*/ | highlight link tangleScenarioSetup SpecialChar " Our C++ files can have mu code in scenarios, so highlight mu comments like " regular comments. syntax match muComment /# .*$/ | highlight link muComment Comment |