From 26785f2a7c2937765f1c0c9e26ce6b80aa4f8dfe Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Wed, 8 Apr 2015 00:13:11 -0700 Subject: 1031 - stop clearing recipes after every test I think the string-equal scenarios are failing to fail. But we'll fix them once we wrap up test isolation. --- cpp/000organization | 1 + cpp/010vm | 10 ++++++++-- cpp/011load | 7 ++++++- cpp/013run | 3 +-- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/cpp/000organization b/cpp/000organization index 6c513809..bf703f05 100644 --- a/cpp/000organization +++ b/cpp/000organization @@ -98,6 +98,7 @@ // End Globals int main(int argc, char* argv[]) { + // End One-time Setup return 0; // End Main } diff --git a/cpp/010vm b/cpp/010vm index 82544193..7116b555 100644 --- a/cpp/010vm +++ b/cpp/010vm @@ -132,11 +132,17 @@ void setup_recipes() { assert(Next_recipe_number == COPY); Next_recipe_number++; // End Primitive Recipe Numbers. +} +//: We could just reset the recipe table after every test, but that gets slow +//: all too quickly. Instead, initialize the common stuff just once at +//: startup, and carefully undo each test's additions after itself. +:(before "End One-time Setup") + setup_recipes(); + load("core.mu"); assert(Next_recipe_number < 100); Next_recipe_number = 100; -} :(before "End Setup") - setup_recipes(); + Next_recipe_number = 100; // consistent new numbers for each test diff --git a/cpp/011load b/cpp/011load index 5657486b..28f63521 100644 --- a/cpp/011load +++ b/cpp/011load @@ -24,6 +24,7 @@ vector add_recipes(istream& in) { // Command Handlers if (command == "recipe") { result.push_back(add_recipe(in)); + recipes_added_by_test.push_back(result.back()); } // End Command Handlers else { @@ -36,7 +37,7 @@ vector add_recipes(istream& in) { recipe_number add_recipe(istream& in) { skip_comments_and_newlines(in); string recipe_name = next_word(in); -//? cout << "recipe name: ^" << recipe_name << "$\n"; //? 2 +//? cout << "recipe name: ^" << recipe_name << "$\n"; //? 3 if (recipe_name.empty()) raise << "empty recipe name\n"; //? raise << "empty recipe name in " << in.str() << '\n'; @@ -45,6 +46,10 @@ recipe_number add_recipe(istream& in) { //? cout << "AAA: " << recipe_name << " is now " << Recipe_number[recipe_name] << '\n'; //? 1 } recipe_number r = Recipe_number[recipe_name]; + if (Recipe.find(r) != Recipe.end()) { + raise << "redefining recipe " << Recipe[r].name << "\n"; + Recipe.erase(r); + } //? cout << recipe_name << ": adding recipe " << r << '\n'; //? 3 skip_whitespace(in); diff --git a/cpp/013run b/cpp/013run index 4917271b..e226bc01 100644 --- a/cpp/013run +++ b/cpp/013run @@ -80,8 +80,6 @@ inline bool done(routine& rr) { return running_at(rr) >= steps(rr).size(); } -:(after "int main") - load("core.mu"); :(before "End Main") if (argc > 1) { setup(); @@ -125,6 +123,7 @@ void run(string form) { :(before "End Setup") for (size_t i = 0; i < recipes_added_by_test.size(); ++i) { +//? cout << "AAA clearing " << Recipe[recipes_added_by_test[i]].name << '\n'; //? 1 Recipe_number.erase(Recipe[recipes_added_by_test[i]].name); Recipe.erase(recipes_added_by_test[i]); } -- cgit 1.4.1-2-gfad0 a id='n2' href='#n2'>2 3 4 5 6 7