about summary refs log tree commit diff stats
path: root/cpp/050scenario.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-05-04 15:06:46 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-05-04 15:06:46 -0700
commit7746981679e36f2138b3f2008e472933a98c6a76 (patch)
tree55e17e007ff26f2f35470fc1f6070b361774b642 /cpp/050scenario.cc
parent0bec72e623e6b5bf42583111fd88c5dea60279ef (diff)
downloadmu-7746981679e36f2138b3f2008e472933a98c6a76.tar.gz
1259 - better failure messages for mu scenarios
Diffstat (limited to 'cpp/050scenario.cc')
-rw-r--r--cpp/050scenario.cc14
1 files changed, 12 insertions, 2 deletions
diff --git a/cpp/050scenario.cc b/cpp/050scenario.cc
index 80778c39..07279d39 100644
--- a/cpp/050scenario.cc
+++ b/cpp/050scenario.cc
@@ -92,8 +92,11 @@ for (index_t i = 0; i < Scenarios.size(); ++i) {
   if (Passed) cerr << ".";
 }
 
+:(before "End Globals")
+const scenario* Current_scenario = NULL;
 :(code)
 void run_mu_scenario(const scenario& s) {
+  Current_scenario = &s;
   bool not_already_inside_test = !Trace_stream;
   if (not_already_inside_test) {
     Trace_file = s.name;
@@ -110,6 +113,7 @@ void run_mu_scenario(const scenario& s) {
     Trace_stream = NULL;
     Trace_file = "";
   }
+  Current_scenario = NULL;
 }
 
 //:: The special instructions we want to support inside scenarios.
@@ -203,8 +207,14 @@ void check_memory(const string& s) {
     if (locations_checked.find(address) != locations_checked.end())
       raise << "duplicate expectation for location " << address << '\n';
     trace("run") << "checking location " << address;
-    if (Memory[address] != value)
-      raise << "expected location " << address << " to contain " << value << " but saw " << Memory[address] << '\n';
+    if (Memory[address] != value) {
+      if (Current_scenario)
+        raise << "\nF - " << Current_scenario->name << ": expected location " << address << " to contain " << value << " but saw " << Memory[address] << '\n';
+      else
+        raise << "expected location " << address << " to contain " << value << " but saw " << Memory[address] << '\n';
+      Passed = false;
+      return;
+    }
     locations_checked.insert(address);
   }
 }