about summary refs log tree commit diff stats
path: root/050scenario.cc
diff options
context:
space:
mode:
Diffstat (limited to '050scenario.cc')
-rw-r--r--050scenario.cc42
1 files changed, 11 insertions, 31 deletions
diff --git a/050scenario.cc b/050scenario.cc
index 57516569..aa914163 100644
--- a/050scenario.cc
+++ b/050scenario.cc
@@ -1,9 +1,8 @@
 //: Mu scenarios. This will get long, but these are the tests we want to
 //: support in this layer.
 
-//: You can use variable names in scenarios, but for the most part we'll use
-//: raw location numbers, because that lets us make assertions on memory.
-//: Tests should avoid abstraction as far as possible.
+//: We avoid raw numeric locations in Mu -- except in scenarios, where they're
+//: handy to check the values of specific variables
 :(scenarios run_mu_scenario)
 :(scenario scenario_block)
 scenario foo [
@@ -257,7 +256,8 @@ def scenario-foo [
 //:: The special instructions we want to support inside scenarios.
 //: In a compiler for the mu VM these will require more work.
 
-//: 'run' interprets a string as a set of instructions
+//: 'run' is a purely lexical convenience to separate the code actually being
+//: tested from any setup or teardown
 
 :(scenario run)
 def main [
@@ -267,34 +267,14 @@ def main [
 ]
 +mem: storing 13 in location 1
 
-:(before "End Primitive Recipe Declarations")
-RUN,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "run", RUN);
-:(before "End Primitive Recipe Checks")
-case RUN: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case RUN: {
-  assert(Name[Next_recipe_ordinal].empty());
-  ostringstream tmp;
-  tmp << "recipe run_" << Next_recipe_ordinal << " [ " << current_instruction().ingredients.at(0).name << " ]";
-  vector<recipe_ordinal> tmp_recipe = load(tmp.str());
-  mark_autogenerated(tmp_recipe.at(0));
-  bind_special_scenario_names(tmp_recipe.at(0));
-  transform_all();
-  if (Trace_stream) {
-    ++Trace_stream->callstack_depth;
-    trace(9998, "trace") << "run: incrementing callstack depth to " << Trace_stream->callstack_depth << end();
-    assert(Trace_stream->callstack_depth < 9000);  // 9998-101 plus cushion
-  }
-  Current_routine->calls.push_front(call(tmp_recipe.at(0)));
-  continue;  // not done with caller; don't increment current_step_index()
+:(before "End Rewrite Instruction(curr, recipe result)")
+if (curr.name == "run") {
+  // Just inline all instructions inside the run block in the containing
+  // recipe. 'run' is basically a comment; pretend it doesn't exist.
+  istringstream in2("[\n"+curr.ingredients.at(0).name+"\n]\n");
+  slurp_body(in2, result);
+  curr.clear();
 }
-:(before "End maybe_make_raw")
-if (starts_with(caller.name, "run_"))
-  r.properties.push_back(pair<string, string_tree*>("raw", NULL));
 
 :(scenario run_multiple)
 def main [