From 0e4a335edc7d4e584924fd6b298156e45d2626c8 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sun, 6 Sep 2015 16:35:46 -0700 Subject: 2175 --- html/050scenario.cc.html | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) (limited to 'html/050scenario.cc.html') diff --git a/html/050scenario.cc.html b/html/050scenario.cc.html index db392a7c..e6184407 100644 --- a/html/050scenario.cc.html +++ b/html/050scenario.cc.html @@ -15,14 +15,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 1.05em; } .cSpecial { color: #008000; } .SalientComment { color: #00ffff; } -.Identifier { color: #804000; } +.traceContains { color: #008000; } +.CommentedCode { color: #6c6c6c; } .traceAbsent { color: #c00000; } .Comment { color: #9090ff; } .Delimiter { color: #a04060; } .Special { color: #ff6060; } -.CommentedCode { color: #6c6c6c; } +.Identifier { color: #804000; } .Constant { color: #00a0a0; } -.traceContains { color: #008000; } --> @@ -96,6 +96,7 @@ struct scenario { :(before "End Globals") vector<scenario> Scenarios; +set<string> Scenario_names; //:: Parse the 'scenario' form. //: Simply store the text of the scenario. @@ -107,10 +108,11 @@ else if (command == " :(code) scenario parse_scenario(istream& in) { -//? cerr << "parse scenario\n"; //? 1 scenario result; result.name = next_word(in); -//? cerr << "scenario: " << result.name << '\n'; //? 2 + if (Scenario_names.find(result.name) != Scenario_names.end()) + raise << "duplicate scenario name: " << result.name << '\n' << end(); + Scenario_names.insert(result.name); skip_whitespace_and_comments(in); assert(in.peek() == '['); // scenarios are take special 'code' strings so we need to ignore brackets @@ -119,7 +121,6 @@ scenario parse_scenario(istream& in// delete [] delimiters assert(result.to_run.at(0) == '['); result.to_run.erase(0, 1); -//? cerr << (int)result.to_run.at(SIZE(result.to_run)-1) << '\n'; //? 1 assert(result.to_run.at(SIZE(result.to_run)-1) == ']'); result.to_run.erase(SIZE(result.to_run)-1); return result; @@ -145,8 +146,7 @@ scenario foo [ time_t mu_time; time(&mu_time); cerr << "\nMu tests: " << ctime(&mu_time); for (long long int i = 0; i < SIZE(Scenarios); ++i) { -//? cerr << Passed << '\n'; //? 1 -//? cerr << i << ": " << Scenarios.at(i).name << '\n'; //? 7 +//? cerr << i << ": " << Scenarios.at(i).name << '\n'; run_mu_scenario(Scenarios.at(i)); if (Passed) cerr << "."; } @@ -167,7 +167,7 @@ const scenario* Current_scenario = NULL(const scenario& s) { Current_scenario = &s; bool not_already_inside_test = !Trace_stream; -//? cerr << s.name << '\n'; //? 12 +//? cerr << s.name << '\n'; if (not_already_inside_test) { Trace_file = s.name; Trace_stream = new trace_stream; @@ -206,7 +206,7 @@ recipe scenario-foo [ +warn: redefining recipe scenario-foo :(after "bool warn_on_redefine(const string& recipe_name)") -if (recipe_name.find("scenario-") == 0) return true; + if (recipe_name.find("scenario-") == 0) return true; //:: The special instructions we want to support inside scenarios. //: In a compiler for the mu VM these will require more work. @@ -214,7 +214,6 @@ if (recipe_name.fi //: 'run' interprets a string as a set of instructions :(scenario run) -#? % Trace_stream->dump_layer = "all"; recipe main [ run [ 1:number <- copy 13 @@ -228,14 +227,11 @@ RUN, Recipe_ordinal["run"] = RUN; :(before "End Primitive Recipe Implementations") case RUN: { -//? cout << "recipe " << current_instruction().ingredients.at(0).name << '\n'; //? 1 ostringstream tmp; tmp << "recipe run" << Next_recipe_ordinal << " [ " << current_instruction().ingredients.at(0).name << " ]"; -//? Show_rest_of_stream = true; //? 1 vector<recipe_ordinal> tmp_recipe = load(tmp.str()); bind_special_scenario_names(tmp_recipe.at(0)); transform_all(); -//? cout << tmp_recipe.at(0) << ' ' << Recipe_ordinal["main"] << '\n'; //? 1 Current_routine->calls.push_front(call(tmp_recipe.at(0))); continue; // not done with caller; don't increment current_step_index() } @@ -286,7 +282,6 @@ Recipe_ordinal["memory-should-contain"] :(before "End Primitive Recipe Implementations") case MEMORY_SHOULD_CONTAIN: { if (!Passed) break; -//? cout << current_instruction().ingredients.at(0).name << '\n'; //? 1 check_memory(current_instruction().ingredients.at(0).name); break; } @@ -456,10 +451,8 @@ case TRACE_SHOULD_CONTAIN: { // simplified version of check_trace_contents() that emits warnings rather // than just printing to stderr bool check_trace(const string& expected) { -//? cerr << "AAA " << expected << '\n'; //? 1 Trace_stream->newline(); vector<trace_line> expected_lines = parse_trace(expected); -//? cerr << "BBB " << SIZE(expected_lines) << '\n'; //? 1 if (expected_lines.empty()) return true; long long int curr_expected_line = 0; for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { @@ -468,7 +461,6 @@ bool check_trace(const string& expected// match ++curr_expected_line; if (curr_expected_line == SIZE(expected_lines)) { -//? cerr << "ZZZ\n"; //? 1 return true; } } @@ -658,12 +650,11 @@ recipe main [ :(code) // just for the scenarios running scenarios in C++ layers void run_mu_scenario(const string& form) { -//? cerr << form << '\n'; //? 1 + Scenario_names.clear(); istringstream in(form); in >> std::noskipws; skip_whitespace_and_comments(in); string _scenario = next_word(in); -//? cout << _scenario << '\n'; //? 2 assert(_scenario == "scenario"); scenario s = parse_scenario(in); run_mu_scenario(s); -- cgit 1.4.1-2-gfad0