diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-06-19 13:37:11 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-06-19 13:37:11 -0700 |
commit | fc52705f4956df9a756b902b187f31799c1451a4 (patch) | |
tree | 634a3dc201a2fb32a00f1ab9ae50b6818fd99732 | |
parent | 8fb0e672c2f5431141d58128f623d1cc02d67bb8 (diff) | |
download | mu-fc52705f4956df9a756b902b187f31799c1451a4.tar.gz |
1598
Some tests weren't actually running for the past 5 days. Performed 5 why's.
-rw-r--r-- | 013literal_string.cc | 23 | ||||
-rw-r--r-- | 050scenario.cc | 7 | ||||
-rw-r--r-- | repl.mu | 2 |
3 files changed, 27 insertions, 5 deletions
diff --git a/013literal_string.cc b/013literal_string.cc index 60fbd266..f8445c26 100644 --- a/013literal_string.cc +++ b/013literal_string.cc @@ -62,10 +62,12 @@ bool code_string(istream& in, ostringstream& out) { // Read a regular string. Regular strings can only contain other regular // strings. -void slurp_quoted_comment_oblivious(istream& in, ostream& out) { +void slurp_quoted_comment_oblivious(istream& in, ostringstream& out) { +//? cerr << "comment oblivious\n"; //? 1 int brace_depth = 1; while (!in.eof()) { char c = in.get(); +//? cerr << '%' << (int)c << ' ' << brace_depth << ": " << out.str() << "%$\n"; //? 1 //? cout << (int)c << ": " << brace_depth << '\n'; //? 2 if (c == '\\') { out << static_cast<char>(in.get()); @@ -84,9 +86,15 @@ void slurp_quoted_comment_oblivious(istream& in, ostream& out) { } // Read a code string. Code strings can contain either code or regular strings. -void slurp_quoted_comment_aware(istream& in, ostream& out) { +void slurp_quoted_comment_aware(istream& in, ostringstream& out) { +//? cerr << "comment aware\n"; //? 1 char c; while (in >> c) { +//? cerr << '^' << (int)c << ": " << out.str() << "$\n"; //? 1 + if (c == '\\') { + out << static_cast<char>(in.get()); + continue; + } if (c == '#') { out << c; while (!in.eof() && in.peek() != '\n') out << static_cast<char>(in.get()); @@ -99,8 +107,10 @@ void slurp_quoted_comment_aware(istream& in, ostream& out) { continue; } out << c; - if (c == ']') break; + if (c == ']') return; } + raise << "unbalanced '['\n"; + out.clear(); } :(after "reagent::reagent(string s)") @@ -154,6 +164,13 @@ recipe main [ ] +parse: ingredient: {name: "abc [def", properties: [_: "literal-string"]} +:(scenario string_literal_escaped_comment_aware) +recipe main [ + 1:address:array:character <- copy [ +abc \\\[def] +] ++parse: ingredient: {name: "\nabc \[def", properties: [_: "literal-string"]} + :(scenario string_literal_and_comment) recipe main [ 1:address:array:character <- copy [abc] # comment diff --git a/050scenario.cc b/050scenario.cc index 1f0db4ac..fd59bf44 100644 --- a/050scenario.cc +++ b/050scenario.cc @@ -74,14 +74,17 @@ scenario parse_scenario(istream& in) { //? cerr << "parse scenario\n"; //? 1 scenario result; result.name = next_word(in); -//? cerr << "scenario: " << result.name << '\n'; //? 1 +//? cerr << "scenario: " << result.name << '\n'; //? 2 skip_whitespace_and_comments(in); assert(in.peek() == '['); // scenarios are take special 'code' strings so we need to ignore brackets // inside comments result.to_run = slurp_quoted(in); // delete [] delimiters + assert(result.to_run.at(0) == '['); result.to_run.erase(0, 1); +//? cerr << (int)result.to_run.at(SIZE(result.to_run)-1) << '\n'; //? 1 + assert(result.to_run.at(SIZE(result.to_run)-1) == ']'); result.to_run.erase(SIZE(result.to_run)-1); return result; } @@ -135,7 +138,7 @@ void run_mu_scenario(const scenario& s) { Trace_stream = new trace_stream; setup(); } -//? cerr << '^' << s.to_run << "$\n"; //? 3 +//? cerr << '^' << s.to_run << "$\n"; //? 4 run("recipe "+s.name+" [ " + s.to_run + " ]"); if (not_already_inside_test && Trace_stream) { teardown(); diff --git a/repl.mu b/repl.mu index dd0000a5..c9a7aaca 100644 --- a/repl.mu +++ b/repl.mu @@ -669,6 +669,7 @@ scenario read-instruction-backspace-back-into-string [ .\\\[ab . . . ] +#? $print [aaa] #? 1 screen-should-contain-in-color 6:literal/cyan, [ .\\\[ab . . . @@ -754,6 +755,7 @@ scenario read-instruction-assignment-continues-after-backspace [ assume-keyboard [a <-«- ] replace-in-keyboard 171:literal/«, 8:literal/backspace +#? $print [aaa] #? 1 run [ read-instruction keyboard:address, screen:address ] |