diff options
-rw-r--r-- | cpp/000organization | 1 | ||||
-rw-r--r-- | cpp/010vm | 10 | ||||
-rw-r--r-- | cpp/011load | 7 | ||||
-rw-r--r-- | 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<recipe_number> 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<recipe_number> 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]); } |