about summary refs log tree commit diff stats
path: root/cpp
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
parent0bec72e623e6b5bf42583111fd88c5dea60279ef (diff)
downloadmu-7746981679e36f2138b3f2008e472933a98c6a76.tar.gz
1259 - better failure messages for mu scenarios
Diffstat (limited to 'cpp')
-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);
   }
 }
185'>185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231