about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-04-20 10:19:35 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-04-20 10:19:35 -0700
commit11fa4fe1f51f2762c3c33dd33794096842d2707a (patch)
tree3025ee73910a86b7d0a6c6eeaf138bb532e6f308
parent6a1fdc9556c5476b65e7d8cdaf885458dd230aac (diff)
downloadmu-11fa4fe1f51f2762c3c33dd33794096842d2707a.tar.gz
1108 - check for typos in memory expectations in scenarios
-rw-r--r--cpp/.traces/parse_scenario_memory_expectation_duplicate5
-rw-r--r--cpp/050scenario15
2 files changed, 20 insertions, 0 deletions
diff --git a/cpp/.traces/parse_scenario_memory_expectation_duplicate b/cpp/.traces/parse_scenario_memory_expectation_duplicate
new file mode 100644
index 00000000..b167144e
--- /dev/null
+++ b/cpp/.traces/parse_scenario_memory_expectation_duplicate
@@ -0,0 +1,5 @@
+parse/0: reading scenario foo
+parse/0: scenario will run: a <- b
+parse/0: memory expectation: *1 == 0
+warn/0: duplicate expectation for location 1: 0 -> 1
+parse/0: memory expectation: *1 == 1
diff --git a/cpp/050scenario b/cpp/050scenario
index 9295752c..9fe50f2d 100644
--- a/cpp/050scenario
+++ b/cpp/050scenario
@@ -53,6 +53,19 @@ scenario foo [
 ]
 +parse: scenario will run: a <- b
 
+:(scenario "parse_scenario_memory_expectation_duplicate")
+hide warnings
+scenario foo [
+  run [
+    a <- b
+  ]
+  memory should contain [
+    1 <- 0
+    1 <- 1
+  ]
+]
++warn: duplicate expectation for location 1: 0 -> 1
+
 :(before "End Command Handlers")
 else if (command == "scenario") {
 //?   cout << "AAA scenario\n"; //? 1
@@ -124,6 +137,8 @@ void handle_scenario_memory_directive(istream& in, scenario& out) {
     string _assign;  in >> _assign;  assert(_assign == "<-");
     skip_whitespace_and_comments(in);
     int value = 0;  in >> value;
+    if (out.memory_expectations.find(address) != out.memory_expectations.end())
+      raise << "duplicate expectation for location " << address << ": " << out.memory_expectations[address] << " -> " << value << '\n';
     out.memory_expectations[address] = value;
     trace("parse") << "memory expectation: *" << address << " == " << value;
   }