about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-07-15 18:05:28 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-07-15 18:05:28 -0700
commitd6c9fe6305ed9775c5ad814dee45e405da3fbecd (patch)
tree24082cb97471fcce002ac4b274ec961807110b04
parenta826f854aef8480a6ed3e1e6f0e74e280b852447 (diff)
downloadmu-d6c9fe6305ed9775c5ad814dee45e405da3fbecd.tar.gz
1787 - clear warnings between runs
-rw-r--r--081run_interactive.cc38
-rw-r--r--edit.mu30
2 files changed, 39 insertions, 29 deletions
diff --git a/081run_interactive.cc b/081run_interactive.cc
index bd5a6496..ab13291d 100644
--- a/081run_interactive.cc
+++ b/081run_interactive.cc
@@ -30,6 +30,7 @@ case RUN_INTERACTIVE: {
   if (!new_code_pushed_to_stack) {
     products.at(0).push_back(0);
     products.at(1).push_back(warnings_from_trace());
+    clean_up_interactive();
     break;  // done with this instruction
   }
   else {
@@ -49,8 +50,6 @@ bool run_interactive(long long int address) {
     Recipe_ordinal["interactive"] = Next_recipe_ordinal++;
   string command = trim(strip_comments(to_string(address)));
   if (command.empty()) return false;
-//?   tb_shutdown(); //? 1
-//?   cerr << command << '\n'; //? 2
   Recipe.erase(Recipe_ordinal["interactive"]);
   Hide_warnings = true;
   if (!Trace_stream) {
@@ -61,10 +60,7 @@ bool run_interactive(long long int address) {
   // call run(string) but without the scheduling
   load("recipe interactive [\n"+command+"\n]\n");
   transform_all();
-  if (trace_count("warn") > 0) {
-    Hide_warnings = false;
-    return false;
-  }
+  if (trace_count("warn") > 0) return false;
   Running_interactive = true;
   Current_routine->calls.push_front(call(Recipe_ordinal["interactive"]));
   return true;
@@ -76,11 +72,13 @@ if (current_recipe_name() == "interactive") clean_up_interactive();
 if (current_recipe_name() == "interactive") clean_up_interactive();
 :(code)
 void clean_up_interactive() {
-//?   static int foo = 0; //? 1
   Hide_warnings = false;
   Running_interactive = false;
-//?   ++foo; //? 1
-//?   if (foo == 1) tb_init(); //? 1
+  // hack: assume collect_layer isn't set anywhere else
+  if (Trace_stream->collect_layer == "warn") {
+    delete Trace_stream;
+    Trace_stream = NULL;
+  }
 }
 
 :(scenario "run_interactive_returns_stringified_result")
@@ -132,27 +130,20 @@ if (Running_interactive) {
 :(code)
 void record_products(const instruction& instruction, const vector<vector<double> >& products) {
   ostringstream out;
-//?   cerr << current_instruction().to_string() << '\n'; //? 1
   for (long long int i = 0; i < SIZE(products); ++i) {
     // string
     if (i < SIZE(instruction.products)) {
-//?       cerr << "AA\n"; //? 1
-//?       cerr << instruction.products.size() << " vs " << i << '\n'; //? 1
       if (is_string(instruction.products.at(i))) {
-//?         cerr << "BB\n"; //? 1
         assert(scalar(products.at(i)));
         out << to_string(products.at(i).at(0)) << '\n';
         continue;
       }
       // End Record Product Special-cases
     }
-    for (long long int j = 0; j < SIZE(products.at(i)); ++j) {
-//?       cerr << "aa: " << i << ", " << j << ": " << products.at(i).at(j) << '\n'; //? 1
-        out << products.at(i).at(j) << ' ';
-    }
+    for (long long int j = 0; j < SIZE(products.at(i)); ++j)
+      out << products.at(i).at(j) << ' ';
     out << '\n';
   }
-//?   cerr << "aa: {\n" << out.str() << "}\n"; //? 2
   Most_recent_results = out.str();
 }
 :(before "Complete Call Fallthrough")
@@ -194,17 +185,13 @@ string to_string(long long int address) {
     // todo: unicode
     tmp << (char)(int)Memory[curr];
   }
-//?   tb_shutdown(); //? 1
-//?   cerr << tmp.str() << '\n'; //? 1
   return tmp.str();
 }
 
 long long int stringified_value_of_location(long long int address) {
   // convert to string
   ostringstream out;
-//?   trace(1, "foo") << "a: " << address; //? 1
   out << Memory[address];
-//?   trace(1, "foo") << "b: " << Memory[address]; //? 1
   return new_string(out.str());
 }
 
@@ -244,13 +231,6 @@ case RELOAD: {
   Loading_interactive = true;
   Hide_warnings = true;
   load(to_string(ingredients.at(0).at(0)));
-//?   static int foo = 0;
-//?   if (++foo == 2) {
-//?     tb_shutdown();
-//?     cerr << Recipe_ordinal["new-add"] << '\n';
-//?     cerr << Recipe[Recipe_ordinal["new-add"]].steps[2].to_string() << '\n';
-//?     exit(0);
-//?   }
   transform_all();
   Hide_warnings = false;
   Loading_interactive = false;
diff --git a/edit.mu b/edit.mu
index e7674f29..5141b0f7 100644
--- a/edit.mu
+++ b/edit.mu
@@ -2055,6 +2055,8 @@ recipe run-sandboxes [
     response:address:address:array:character <- get-address curr:address:sandbox-data/deref, response:offset
     warnings:address:address:array:character <- get-address curr:address:sandbox-data/deref, warnings:offset
     response:address:address:array:character/deref, warnings:address:address:array:character/deref <- run-interactive data:address:address:array:character/deref
+#?     $print warnings:address:address:array:character/deref, [ ], warnings:address:address:array:character/deref/deref, [ 
+#? ] #? 1
     curr:address:sandbox-data <- get curr:address:sandbox-data/deref, next-sandbox:offset
     loop
   }
@@ -2164,6 +2166,34 @@ scenario run-instruction-and-print-warnings [
   ]
 ]
 
+scenario run-instruction-and-print-warnings-only-once [
+  $close-trace  # trace too long for github
+  assume-screen 100:literal/width, 10:literal/height
+  # left editor is empty
+  1:address:array:character <- new []
+  # right editor contains an illegal instruction
+  2:address:array:character <- new [get 1234:number, foo:offset]
+  3:address:programming-environment-data <- new-programming-environment screen:address, 1:address:array:character, 2:address:array:character
+  # run the code in the editors multiple times
+  assume-console [
+    press 65526  # F10
+    press 65526  # F10
+  ]
+  run [
+    event-loop screen:address, console:address, 3:address:programming-environment-data
+  ]
+  # check that screen prints error message just once
+  screen-should-contain [
+    .                                                                                 run (F10)          .
+    .                                                  ┊                                                 .
+    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
+    .                                                  ┊get 1234:number, foo:offset                      .
+    .                                                  ┊unknown element foo in container number          .
+    .                                                  ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
+    .                                                  ┊                                                 .
+  ]
+]
+
 recipe editor-contents [
   local-scope
   editor:address:editor-data <- next-ingredient