Some tests weren't actually running for the past 5 days.
Performed 5 why's.
This commit is contained in:
Kartik K. Agaram 2015-06-19 13:37:11 -07:00
parent 8fb0e672c2
commit fc52705f49
3 changed files with 27 additions and 5 deletions

View File

@ -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

View File

@ -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();

View File

@ -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
]