about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--029tools.cc26
-rw-r--r--050scenario.cc26
-rw-r--r--051scenario_test.mu2
-rw-r--r--060string.mu4
-rw-r--r--061channel.mu2
-rw-r--r--071print.mu2
-rw-r--r--makefile2
7 files changed, 37 insertions, 27 deletions
diff --git a/029tools.cc b/029tools.cc
index 63addeb9..50e17643 100644
--- a/029tools.cc
+++ b/029tools.cc
@@ -2,7 +2,7 @@
 
 :(scenario trace)
 recipe main [
-  trace [foo], [this is a trace in mu]
+  trace 1, [foo], [this is a trace in mu]
 ]
 +foo: this is a trace in mu
 
@@ -12,15 +12,25 @@ TRACE,
 Recipe_ordinal["trace"] = TRACE;
 :(before "End Primitive Recipe Implementations")
 case TRACE: {
-  if (SIZE(current_instruction().ingredients) != 2) {
-    raise << current_recipe_name() << ": 'trace' takes two ingredients rather than '" << current_instruction().to_string() << "'\n" << end();
+  if (SIZE(current_instruction().ingredients) < 3) {
+    raise << current_recipe_name() << ": 'trace' takes three or more ingredients rather than '" << current_instruction().to_string() << "'\n" << end();
     break;
   }
-  assert(is_literal(current_instruction().ingredients.at(0)));
-  string label = current_instruction().ingredients.at(0).name;
-  assert(is_literal(current_instruction().ingredients.at(1)));
-  string message = current_instruction().ingredients.at(1).name;
-  trace(1, label) << message << end();
+  if (!scalar(ingredients.at(0))) {
+    raise << current_recipe_name() << ": first ingredient of 'trace' should be a number (depth), but got " << current_instruction().ingredients.at(0).original_string << '\n' << end();
+    break;
+  }
+  long long int depth = ingredients.at(0).at(0);
+  if (!is_literal_string(current_instruction().ingredients.at(1))) {
+    raise << current_recipe_name() << ": second ingredient of 'trace' should be a literal string (label), but got " << current_instruction().ingredients.at(1).original_string << '\n' << end();
+    break;
+  }
+  string label = current_instruction().ingredients.at(1).name;
+  ostringstream out;
+  for (long long int i = 2; i < SIZE(current_instruction().ingredients); ++i) {
+    out << print_mu(current_instruction().ingredients.at(i), ingredients.at(i));
+  }
+  trace(depth, label) << out.str() << end();
   break;
 }
 
diff --git a/050scenario.cc b/050scenario.cc
index 5a1df05d..29ffc2cb 100644
--- a/050scenario.cc
+++ b/050scenario.cc
@@ -37,7 +37,7 @@ scenario foo [
 scenario foo [
   run [
     1:number <- copy 13
-    trace [a], [a b c]
+    trace 1, [a], [a b c]
   ]
   memory-should-contain [
     1 <- 13
@@ -403,7 +403,7 @@ recipe main [
     a: d
   ]
 ]
-+warn: missing [b] in trace layer a
++warn: missing [b] in trace with label a
 
 :(before "End Primitive Recipe Declarations")
 TRACE_SHOULD_CONTAIN,
@@ -438,7 +438,7 @@ bool check_trace(const string& expected) {
   }
 
   raise << "missing [" << expected_lines.at(curr_expected_line).contents << "] "
-        << "in trace layer " << expected_lines.at(curr_expected_line).label << '\n' << end();
+        << "in trace with label " << expected_lines.at(curr_expected_line).label << '\n' << end();
   Passed = false;
   return false;
 }
@@ -460,27 +460,27 @@ vector<trace_line> parse_trace(const string& expected) {
 % Hide_warnings = true;
 recipe main [
   run [
-    trace [a], [b]
+    trace 1, [a], [b]
   ]
   trace-should-contain [
     a: b
     a: d
   ]
 ]
-+warn: missing [d] in trace layer a
++warn: missing [d] in trace with label a
 
 :(scenario trace_check_passes_silently)
 % Scenario_testing_scenario = true;
 % Hide_warnings = true;
 recipe main [
   run [
-    trace [a], [b]
+    trace 1, [a], [b]
   ]
   trace-should-contain [
     a: b
   ]
 ]
--warn: missing [b] in trace layer a
+-warn: missing [b] in trace with label a
 $warn: 0
 
 //: 'trace-should-not-contain' is like the '-' lines in our scenarios so far
@@ -492,13 +492,13 @@ $warn: 0
 % Hide_warnings = true;
 recipe main [
   run [
-    trace [a], [b]
+    trace 1, [a], [b]
   ]
   trace-should-not-contain [
     a: b
   ]
 ]
-+warn: unexpected [b] in trace layer a
++warn: unexpected [b] in trace with label a
 
 :(before "End Primitive Recipe Declarations")
 TRACE_SHOULD_NOT_CONTAIN,
@@ -519,7 +519,7 @@ bool check_trace_missing(const string& in) {
   vector<trace_line> lines = parse_trace(in);
   for (long long int i = 0; i < SIZE(lines); ++i) {
     if (trace_count(lines.at(i).label, lines.at(i).contents) != 0) {
-      raise << "unexpected [" << lines.at(i).contents << "] in trace layer " << lines.at(i).label << '\n' << end();
+      raise << "unexpected [" << lines.at(i).contents << "] in trace with label " << lines.at(i).label << '\n' << end();
       Passed = false;
       return false;
     }
@@ -535,7 +535,7 @@ recipe main [
     a: b
   ]
 ]
--warn: unexpected [b] in trace layer a
+-warn: unexpected [b] in trace with label a
 $warn: 0
 
 :(scenario trace_negative_check_warns_on_any_unexpected_line)
@@ -543,14 +543,14 @@ $warn: 0
 % Hide_warnings = true;
 recipe main [
   run [
-    trace [a], [d]
+    trace 1, [a], [d]
   ]
   trace-should-not-contain [
     a: b
     a: d
   ]
 ]
-+warn: unexpected [d] in trace layer a
++warn: unexpected [d] in trace with label a
 
 //: Minor detail: ignore 'system' calls in scenarios, since anything we do
 //: with them is by definition impossible to test through mu.
diff --git a/051scenario_test.mu b/051scenario_test.mu
index a36897c4..7767451b 100644
--- a/051scenario_test.mu
+++ b/051scenario_test.mu
@@ -62,7 +62,7 @@ scenario check_trace_negative [
 
 scenario check_trace_instruction [
   run [
-    trace [foo], [aaa]
+    trace 1, [foo], [aaa]
   ]
   trace-should-contain [
     foo: aaa
diff --git a/060string.mu b/060string.mu
index e6cd72f5..cc180bb1 100644
--- a/060string.mu
+++ b/060string.mu
@@ -8,13 +8,13 @@ recipe string-equal [
   b-len:number <- length *b
   # compare lengths
   {
-    trace [string-equal], [comparing lengths]
+    trace 99, [string-equal], [comparing lengths]
     length-equal?:boolean <- equal a-len, b-len
     break-if length-equal?
     reply 0
   }
   # compare each corresponding character
-  trace [string-equal], [comparing characters]
+  trace 99, [string-equal], [comparing characters]
   i:number <- copy 0
   {
     done?:boolean <- greater-or-equal i, a-len
diff --git a/061channel.mu b/061channel.mu
index 9f4ea619..d0c7ae2f 100644
--- a/061channel.mu
+++ b/061channel.mu
@@ -365,7 +365,7 @@ F buffer-lines-blocks-until-newline: channel should be empty after writing 'b']
     9:boolean/completed? <- not 8:boolean
     assert 9:boolean/completed?, [
 F buffer-lines-blocks-until-newline: channel should contain data after writing newline]
-    trace [test], [reached end]
+    trace 1, [test], [reached end]
   ]
   trace-should-contain [
     test: reached end
diff --git a/071print.mu b/071print.mu
index 4a9241a5..7b839390 100644
--- a/071print.mu
+++ b/071print.mu
@@ -101,7 +101,7 @@ recipe print-character [
     break-if bg-color-found?
     bg-color <- copy 0/black
   }
-#?   trace [app], [print character] #? 1
+#?   trace 90, [app], [print character] #? 1
   {
     # if x exists
     # (handle special cases exactly like in the real screen)
diff --git a/makefile b/makefile
index 7b8192ec..d06bc762 100644
--- a/makefile
+++ b/makefile
@@ -1,7 +1,7 @@
 all: mu_bin core.mu
 
 mu_bin: makefile enumerate/enumerate tangle/tangle mu.cc termbox/libtermbox.a
-	c++ -g -O3 -Wall -Wextra -fno-strict-aliasing mu.cc termbox/libtermbox.a -o mu_bin
+	c++ -g -Wall -Wextra -fno-strict-aliasing mu.cc termbox/libtermbox.a -o mu_bin
 
 # To see what the program looks like after all layers have been applied, read
 # mu.cc