From dcc060c7d4ef56b978beb34ddce8d8ffcec94fa6 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 25 Feb 2016 17:17:20 -0800 Subject: 2706 - update html --- html/003trace.cc.html | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) (limited to 'html/003trace.cc.html') diff --git a/html/003trace.cc.html b/html/003trace.cc.html index c19044fb..a835d7ab 100644 --- a/html/003trace.cc.html +++ b/html/003trace.cc.html @@ -123,15 +123,12 @@ struct trace_line { :(before "End Globals") const int Max_depth = 9999; -const int Error_depth = 0; // definitely always print the error that caused death -const int Warning_depth = 1; +const int Error_depth = 0; // definitely always print errors const int App_depth = 2; // temporarily where all mu code will trace to :(before "End Tracing") bool Hide_errors = false; -bool Hide_warnings = false; :(before "End Setup") Hide_errors = false; -Hide_warnings = false; :(before "End Tracing") struct trace_stream { @@ -166,16 +163,14 @@ struct trace_stream { past_lines.push_back(trace_line(curr_depth, trim(curr_label), curr_contents)); // preserve indent in contents if (!Hide_errors && curr_label == "error") cerr << curr_label << ": " << curr_contents << '\n'; - else if (!Hide_warnings && curr_label == "warn") - cerr << curr_label << ": " << curr_contents << '\n'; delete curr_stream; curr_stream = NULL; curr_label.clear(); curr_depth = Max_depth; } - // Useful for debugging. - string readable_contents(string label) { // missing label = everything + // useful for debugging + string readable_contents(string label) { // empty label = show everything ostringstream output; label = trim(label); for (vector<trace_line>::iterator p = past_lines.begin(); p != past_lines.end(); ++p) @@ -190,10 +185,18 @@ struct trace_stream { trace_stream* Trace_stream = NULL; -// Top-level helper. IMPORTANT: can't nest. +// Top-level helper. IMPORTANT: can't nest #define trace(...) !Trace_stream ? cerr /*print nothing*/ : Trace_stream->stream(__VA_ARGS__) -#define raise (!Trace_stream ? (tb_shutdown(),cerr) /*do print*/ : Trace_stream->stream(Warning_depth, "warn")) + +// Errors are a special layer. #define raise_error (!Trace_stream ? (tb_shutdown(),cerr) /*do print*/ : Trace_stream->stream(Error_depth, "error")) +// Inside tests, fail any tests that displayed (unexpected) errors. +// Expected errors in tests should always be hidden and silently checked for. +:(before "End Test Teardown") +if (Passed && !Hide_errors && trace_count("error") > 0) { + Passed = false; + ++Num_failures; +} :(before "End Types") struct end {}; @@ -284,6 +287,7 @@ int trace_count(string label} int trace_count(string label, string line) { + if (!Trace_stream) return 0; long result = 0; for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { if (label == p->label) { @@ -375,14 +379,6 @@ using std::map; using std::set; #include<algorithm> -#include<iostream> -using std::istream; -using std::ostream; -using std::cin; -using std::cout; -using std::cerr; -#include<iomanip> - #include<sstream> using std::istringstream; using std::ostringstream; @@ -399,8 +395,7 @@ using std::ofstream; //: In future layers we'll use the depth field as follows: //: //: Errors will be depth 0. -//: Warnings will be depth 1. -//: Mu 'applications' will be able to use depths 2-100 as they like. +//: Mu 'applications' will be able to use depths 1-100 as they like. //: Primitive statements will occupy 101-9989 const int Initial_callstack_depth = 101; const int Max_callstack_depth = 9989; -- cgit 1.4.1-2-gfad0