about summary refs log tree commit diff stats
path: root/cpp/012run
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-03-16 20:26:59 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-03-16 20:26:59 -0700
commit3c435756bcd997dac981ca78c49c5100eb2211b7 (patch)
tree05524418c430239992558e5b5a82ddbdf133c60d /cpp/012run
parentb589f25a005ad00f6fd888520f9eaaddbd707617 (diff)
downloadmu-3c435756bcd997dac981ca78c49c5100eb2211b7.tar.gz
932 - clean up comments in the tangled c++
Diffstat (limited to 'cpp/012run')
-rw-r--r--cpp/012run32
1 files changed, 23 insertions, 9 deletions
diff --git a/cpp/012run b/cpp/012run
index 42b5d477..3d1395a9 100644
--- a/cpp/012run
+++ b/cpp/012run
@@ -19,7 +19,7 @@ recipe main [
 
 :(before "End Types")
 // Book-keeping while running a recipe.
-// Later layers will change this.
+//: Later layers will change this.
 struct routine {
   recipe_number running_recipe;
   size_t running_at;
@@ -27,11 +27,6 @@ struct routine {
 };
 
 :(code)
-void run(string form) {
-  vector<recipe_number> recipes_added = add_recipes(form);
-  run(recipes_added.front());
-}
-
 void run(recipe_number r) {
   run(routine(r));
 }
@@ -59,9 +54,9 @@ void run(routine rr) {
   }
 }
 
-// Some helpers.
-// We'll need to override these later as we change the definition of routine.
-// Important that they return referrences into the routine.
+//: Some helpers.
+//: We'll need to override these later as we change the definition of routine.
+//: Important that they return referrences into the routine.
 inline size_t& running_at(routine& rr) {
   return rr.running_at;
 }
@@ -92,6 +87,25 @@ if (argc > 1) {
   dump_memory();
 }
 
+//: helper for tests
+
+:(before "End Globals")
+vector<recipe_number> recipes_added_by_test;
+
+:(code)
+void run(string form) {
+  vector<recipe_number> tmp = add_recipes(form);
+  recipes_added_by_test.insert(recipes_added_by_test.end(), tmp.begin(), tmp.end());
+  run(recipes_added_by_test.front());
+}
+
+:(before "End Setup")
+for (size_t i = 0; i < recipes_added_by_test.size(); ++i) {
+  Recipe_number.erase(Recipe[recipes_added_by_test[i]].name);
+  Recipe.erase(recipes_added_by_test[i]);
+}
+recipes_added_by_test.clear();
+
 :(code)
 vector<int> read_memory(reagent x) {
 //?   cout << "read_memory: " << x.to_string() << '\n'; //? 1