about summary refs log tree commit diff stats
path: root/cpp/052scenario_trace
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-04-24 22:49:29 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-04-24 22:49:29 -0700
commit6d8ef6b12d37336a92c7a6b20b4b66f3ab424464 (patch)
tree49c4b2b75ebc85540861b2682e3d48fe958c5dc8 /cpp/052scenario_trace
parent0b0cfb6f1f4579eef463ffcb41ba782ddbd56035 (diff)
downloadmu-6d8ef6b12d37336a92c7a6b20b4b66f3ab424464.tar.gz
1189 - add extensions to all layers
I'm sick of fighting vim's filetype detection. No modeline and files
highlight in random colors. I add a modeline and it stops highlighting
tangle comments. Even though it read my #$%# vimrc! Fuck this shite.
Diffstat (limited to 'cpp/052scenario_trace')
-rw-r--r--cpp/052scenario_trace104
1 files changed, 0 insertions, 104 deletions
diff --git a/cpp/052scenario_trace b/cpp/052scenario_trace
deleted file mode 100644
index 4436ee3f..00000000
--- a/cpp/052scenario_trace
+++ /dev/null
@@ -1,104 +0,0 @@
-//: Support a scenario [ ... ] form at the top level so we can start creating
-//: scenarios in mu just like we do in C++.
-
-:(before "End scenario Fields")
-vector<pair<string, string> > trace_checks;
-vector<pair<string, string> > trace_negative_checks;
-
-:(before "End Scenario Command Handlers")
-else if (scenario_command == "trace") {
-  handle_scenario_trace_directive(inner, x);
-}
-
-:(before "End Scenario Checks")
-check_trace_contents(Scenarios[i]);
-check_trace_negative_contents(Scenarios[i]);
-
-:(code)
-void handle_scenario_trace_directive(istream& in, scenario& out) {
-  if (next_word(in) != "should") {
-    raise << "'trace' directive inside scenario must continue 'trace should'\n";
-  }
-  string s = next_word(in);
-  if (s == "not") {
-    handle_scenario_trace_negative_directive(in, out);
-    return;
-  }
-  if (s != "contain") {
-    raise << "'trace' directive inside scenario must continue 'trace should [not] contain'\n";
-  }
-  skip_bracket(in, "'trace' directive inside scenario must begin with 'trace should contain ['\n");
-  while (true) {
-    skip_whitespace_and_comments(in);
-    if (in.eof()) break;
-    if (in.peek() == ']') break;
-    string curr_line;
-    getline(in, curr_line);
-    istringstream tmp(curr_line);
-    tmp >> std::noskipws;
-    string label = slurp_until(tmp, ':');
-    if (tmp.get() != ' ') {
-      raise << "'trace' directive inside scenario should contain lines of the form 'label: message', instead got " << curr_line;
-      continue;
-    }
-    string message = slurp_rest(tmp);
-    out.trace_checks.push_back(pair<string, string>(label, message));
-    trace("scenario") << "trace: " << label << ": " << message << '\n';
-  }
-  skip_whitespace(in);
-  assert(in.get() == ']');
-}
-
-void handle_scenario_trace_negative_directive(istream& in, scenario& out) {
-  // 'not' already slurped
-  if (next_word(in) != "contain") {
-    raise << "'trace' directive inside scenario must continue 'trace should not contain'\n";
-  }
-  skip_bracket(in, "'trace' directive inside scenario must begin with 'trace should not contain ['\n");
-  while (true) {
-    skip_whitespace_and_comments(in);
-    if (in.eof()) break;
-    if (in.peek() == ']') break;
-    string curr_line;
-    getline(in, curr_line);
-    istringstream tmp(curr_line);
-    tmp >> std::noskipws;
-    string label = slurp_until(tmp, ':');
-    if (tmp.get() != ' ') {
-      raise << "'trace' directive inside scenario should contain lines of the form 'label: message', instead got " << curr_line;
-      continue;
-    }
-    string message = slurp_rest(tmp);
-    out.trace_negative_checks.push_back(pair<string, string>(label, message));
-    trace("scenario") << "trace: " << label << ": " << message << '\n';
-  }
-  skip_whitespace(in);
-  assert(in.get() == ']');
-}
-
-string slurp_rest(istream& in) {
-  ostringstream out;
-  char c;
-  while (in >> c) {
-    out << c;
-  }
-  return out.str();
-}
-
-void check_trace_contents(const scenario& s) {
-  if (s.trace_checks.empty()) return;
-  ostringstream contents;
-  for (size_t i = 0; i < s.trace_checks.size(); ++i) {
-    contents << s.trace_checks[i].first << ": " << s.trace_checks[i].second << "";
-  }
-  CHECK_TRACE_CONTENTS(contents.str());
-}
-
-void check_trace_negative_contents(const scenario& s) {
-  for (size_t i = 0; i < s.trace_negative_checks.size(); ++i) {
-    if (trace_count(s.trace_negative_checks[i].first, s.trace_negative_checks[i].second) > 0) {
-      raise << "trace shouldn't contain " << s.trace_negative_checks[i].first << ": " << s.trace_negative_checks[i].second << '\n';
-      Passed = false;
-    }
-  }
-}