From 94c420905a601c28a4c086f050921a8578bce022 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Wed, 24 Feb 2016 21:04:11 -0800 Subject: 2698 --- 050scenario.cc | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/050scenario.cc b/050scenario.cc index 506bced6..94166f91 100644 --- a/050scenario.cc +++ b/050scenario.cc @@ -294,7 +294,21 @@ void check_memory(const string& s) { skip_whitespace_and_comments(in); string _assign; in >> _assign; assert(_assign == "<-"); skip_whitespace_and_comments(in); - double value = 0; in >> value; + string rhs = next_word(in); + if (!is_integer(rhs) && !is_noninteger(rhs)) { + if (Current_scenario && !Scenario_testing_scenario) + // genuine test in a mu file + raise_error << "\nF - " << Current_scenario->name << ": location " << address << " can't contain non-number " << rhs << '\n' << end(); + else + // just testing scenario support + raise_error << "location " << address << " can't contain non-number " << rhs << '\n' << end(); + if (!Scenario_testing_scenario) { + Passed = false; + ++Num_failures; + } + return; + } + double value = to_double(rhs); if (contains_key(locations_checked, address)) raise_error << "duplicate expectation for location " << address << '\n' << end(); trace(9999, "run") << "checking location " << address << end(); @@ -335,6 +349,7 @@ void check_type(const string& lhs, istream& in) { check_string(address, literal); return; } + // End Scenario Type Cases raise_error << "don't know how to check memory for " << lhs << '\n' << end(); } @@ -412,6 +427,26 @@ recipe main [ +run: checking location 3 +run: checking location 4 +:(scenario memory_invalid_string_check) +% Scenario_testing_scenario = true; +% Hide_errors = true; +recipe main [ + memory-should-contain [ + 1 <- [abc] + ] +] ++error: location 1 can't contain non-number [abc] + +:(scenario memory_check_with_comment) +% Scenario_testing_scenario = true; +% Hide_errors = true; +recipe main [ + memory-should-contain [ + 1 <- 34 # comment + ] +] +-error: location 1 can't contain non-number 34 # comment + :(code) //: 'trace-should-contain' is like the '+' lines in our scenarios so far // Like runs of contiguous '+' lines, order is important. The trace checks -- cgit 1.4.1-2-gfad0