diff options
-rw-r--r-- | 082persist.cc | 14 | ||||
-rw-r--r-- | edit.mu | 15 |
2 files changed, 22 insertions, 7 deletions
diff --git a/082persist.cc b/082persist.cc index 3e53ff6a..f10b44a2 100644 --- a/082persist.cc +++ b/082persist.cc @@ -13,14 +13,18 @@ case RESTORE: { raise << current_recipe_name() << ": 'restore' requires exactly one ingredient, but got " << current_instruction().to_string() << '\n' << end(); break; } - if (!scalar(ingredients.at(0))) { - raise << current_recipe_name() << ": first ingredient of 'restore' should be a literal string, but got " << current_instruction().ingredients.at(0).to_string() << '\n' << end(); + string filename; + if (is_literal_string(current_instruction().ingredients.at(0))) { + filename = current_instruction().ingredients.at(0).name; + } + else if (is_mu_string(current_instruction().ingredients.at(0))) { + filename = read_mu_string(ingredients.at(0).at(0)); + } + else { + raise << current_recipe_name() << ": first ingredient of 'restore' should be a string, but got " << current_instruction().ingredients.at(0).to_string() << '\n' << end(); break; } if (Current_scenario) break; // do nothing in tests - string filename = current_instruction().ingredients.at(0).name; - if (!is_literal(current_instruction().ingredients.at(0))) - filename = to_string(ingredients.at(0).at(0)); string contents = slurp("lesson/"+filename); if (contents.empty()) products.at(0).push_back(0); diff --git a/edit.mu b/edit.mu index fedd9f9f..8c3474b9 100644 --- a/edit.mu +++ b/edit.mu @@ -2932,17 +2932,27 @@ recipe restore-sandboxes [ local-scope env:address:programming-environment-data <- next-ingredient # read all scenarios, pushing them to end of a list of scenarios - filename:number <- copy 0 + suffix:address:array:character <- new [.out] + idx:number <- copy 0 curr:address:address:sandbox-data <- get-address *env, sandbox:offset { + filename:address:array:character <- integer-to-decimal-string idx contents:address:array:character <- restore filename break-unless contents # stop at first error; assuming file didn't exist # create new sandbox for file *curr <- new sandbox-data:type data:address:address:array:character <- get-address **curr, data:offset *data <- copy contents + # restore expected output for sandbox if it exists + { + filename <- string-append filename, suffix + contents <- restore filename + break-unless contents + expected-response:address:address:array:character <- get-address **curr, expected-response:offset + *expected-response <- copy contents + } # increment loop variables - filename <- add filename, 1 + idx <- add idx, 1 curr <- get-address **curr, next-sandbox:offset loop } @@ -3594,6 +3604,7 @@ recipe toggle-expected-response [ # when rendering a sandbox, color it in red/green if expected response exists after +render-sandbox-response [ { + break-unless sandbox-response expected-response:address:array:character <- get *sandbox, expected-response:offset break-unless expected-response # fall-through to print in grey response-is-expected?:boolean <- string-equal expected-response, sandbox-response |