about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-04-29 17:07:40 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-04-29 17:07:40 -0700
commit0cc4f18dd56e2e6a80809d48ef1d1e0fb302029e (patch)
treeffe02c48e563bf88119805529a34e4a85be4d544
parent9da019fcda10240cbce35b6b0b3e148d1219b4a4 (diff)
downloadmu-0cc4f18dd56e2e6a80809d48ef1d1e0fb302029e.tar.gz
1222
-rw-r--r--cpp/.traces/scenario_trace_block4
-rw-r--r--cpp/050scenario.cc3
-rw-r--r--cpp/052scenario_trace.cc26
3 files changed, 28 insertions, 5 deletions
diff --git a/cpp/.traces/scenario_trace_block b/cpp/.traces/scenario_trace_block
new file mode 100644
index 00000000..8729af2c
--- /dev/null
+++ b/cpp/.traces/scenario_trace_block
@@ -0,0 +1,4 @@
+parse/0: reading scenario foo
+scenario/0: +bar: baz
+scenario/0: +bar: floo
+scenario/0: -bar: abc
diff --git a/cpp/050scenario.cc b/cpp/050scenario.cc
index d8152219..e67bb172 100644
--- a/cpp/050scenario.cc
+++ b/cpp/050scenario.cc
@@ -1,4 +1,5 @@
-//: Allow tests to be written in mu files.
+//: Support a scenario [ ... ] form at the top level so we can start creating
+//: scenarios in mu files just like we do in C++.
 
 :(before "End Types")
 struct scenario {
diff --git a/cpp/052scenario_trace.cc b/cpp/052scenario_trace.cc
index 4436ee3f..cf782835 100644
--- a/cpp/052scenario_trace.cc
+++ b/cpp/052scenario_trace.cc
@@ -1,5 +1,23 @@
-//: Support a scenario [ ... ] form at the top level so we can start creating
-//: scenarios in mu just like we do in C++.
+//: Support a trace block inside scenario blocks.
+//: Allows two kinds of assertions:
+//:   trace must contain [ ... ]
+//:   trace must not contain [ ... ]
+
+:(scenarios "parse_scenario")
+:(scenario scenario_trace_block)
+scenario foo [
+  trace should contain [
+    bar: baz
+    bar: floo
+  ]
+  trace should not contain [
+    bar: abc
+  ]
+
+]
++scenario: +bar: baz
++scenario: +bar: floo
++scenario: -bar: abc
 
 :(before "End scenario Fields")
 vector<pair<string, string> > trace_checks;
@@ -43,7 +61,7 @@ void handle_scenario_trace_directive(istream& in, scenario& out) {
     }
     string message = slurp_rest(tmp);
     out.trace_checks.push_back(pair<string, string>(label, message));
-    trace("scenario") << "trace: " << label << ": " << message << '\n';
+    trace("scenario") << '+' << label << ": " << message << '\n';
   }
   skip_whitespace(in);
   assert(in.get() == ']');
@@ -70,7 +88,7 @@ void handle_scenario_trace_negative_directive(istream& in, scenario& out) {
     }
     string message = slurp_rest(tmp);
     out.trace_negative_checks.push_back(pair<string, string>(label, message));
-    trace("scenario") << "trace: " << label << ": " << message << '\n';
+    trace("scenario") << '-' << label << ": " << message << '\n';
   }
   skip_whitespace(in);
   assert(in.get() == ']');