From 0a8b00c06d4a41b3604c7f8c5065d93296848d78 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Fri, 1 May 2015 15:30:51 -0700 Subject: 1230 - start building scenarios out of 'pseudo recipes' --- cpp/049scenario_helpers.cc | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 cpp/049scenario_helpers.cc (limited to 'cpp/049scenario_helpers.cc') diff --git a/cpp/049scenario_helpers.cc b/cpp/049scenario_helpers.cc new file mode 100644 index 00000000..8234c21f --- /dev/null +++ b/cpp/049scenario_helpers.cc @@ -0,0 +1,44 @@ +//: Some pseudo-primitives to support writing tests in mu. +//: When we throw out the C layer these will require more work. + +:(scenario run) +#? % Trace_stream->dump_layer = "all"; +recipe main [ + run [ + 1:integer <- copy 13:literal + ] +] ++mem: storing 13 in location 1 + +:(before "End Globals") +size_t Num_temporary_recipes = 0; +:(before "End Setup") +Num_temporary_recipes = 0; + +:(before "End Primitive Recipe Declarations") +RUN, +:(before "End Primitive Recipe Numbers") +Recipe_number["run"] = RUN; +:(before "End Primitive Recipe Implementations") +case RUN: { +//? cout << "recipe " << current_instruction().ingredients[0].name << '\n'; //? 1 + ostringstream tmp; + tmp << "recipe tmp" << Num_temporary_recipes++ << " [ " << current_instruction().ingredients[0].name << " ]"; + vector tmp_recipe = load(tmp.str()); + transform_all(); +//? cout << tmp_recipe[0] << ' ' << Recipe_number["main"] << '\n'; //? 1 + Current_routine->calls.push(call(tmp_recipe[0])); + continue; // not done with caller; don't increment current_step_index() +} + +:(scenario run_multiple) +recipe main [ + run [ + 1:integer <- copy 13:literal + ] + run [ + 2:integer <- copy 13:literal + ] +] ++mem: storing 13 in location 1 ++mem: storing 13 in location 2 -- cgit 1.4.1-2-gfad0