about summary refs log tree commit diff stats
path: root/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp')
-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;
   }