Break down top of parse stack when needed

Also, start randomizing the edits in the corpus specs
This commit is contained in:
Max Brunsfeld 2015-12-02 11:24:13 -08:00
parent 08d50c25ae
commit d69fef11f9
2 changed files with 81 additions and 29 deletions

View file

@ -97,41 +97,50 @@ describe("Languages", [&]() {
ts_document_parse(doc);
});
it_handles_edit_sequence("repairing an inserted error", [&]() {
ts_document_edit(doc, input->replace(entry.input.size() / 2, 0, "%^&*"));
ts_document_parse(doc);
srand(0);
ts_document_edit(doc, input->undo());
ts_document_parse(doc);
});
for (int i = 0; i < 5; i++) {
size_t edit_position = rand() % entry.input.size();
size_t deletion_amount = rand() % (entry.input.size() - edit_position);
string pos_string = to_string(edit_position);
it_handles_edit_sequence("creating and repairing an inserted error", [&]() {
ts_document_parse(doc);
it_handles_edit_sequence("repairing an inserted error at " + pos_string, [&]() {
ts_document_edit(doc, input->replace(edit_position, 0, "%^&*"));
ts_document_parse(doc);
ts_document_edit(doc, input->replace(entry.input.size() / 2, 0, "%^&*"));
ts_document_parse(doc);
ts_document_edit(doc, input->undo());
ts_document_parse(doc);
});
ts_document_edit(doc, input->undo());
ts_document_parse(doc);
});
it_handles_edit_sequence("creating and repairing an inserted error at " + pos_string, [&]() {
ts_document_parse(doc);
it_handles_edit_sequence("repairing an errant deletion", [&]() {
ts_document_parse(doc);
ts_document_edit(doc, input->replace(edit_position, 0, "%^&*"));
ts_document_edit(doc, input->replace(entry.input.size() / 2, 5, ""));
ts_document_parse(doc);
ts_document_parse(doc);
ts_document_edit(doc, input->undo());
ts_document_parse(doc);
});
ts_document_edit(doc, input->undo());
ts_document_parse(doc);
});
it_handles_edit_sequence("creating and repairing an errant deletion", [&]() {
ts_document_edit(doc, input->replace(entry.input.size() / 2, 5, ""));
ts_document_parse(doc);
it_handles_edit_sequence("repairing an errant deletion at " + pos_string, [&]() {
ts_document_parse(doc);
ts_document_edit(doc, input->undo());
ts_document_parse(doc);
});
ts_document_edit(doc, input->replace(edit_position, deletion_amount, ""));
ts_document_parse(doc);
ts_document_edit(doc, input->undo());
ts_document_parse(doc);
});
it_handles_edit_sequence("creating and repairing an errant deletion at " + pos_string, [&]() {
ts_document_edit(doc, input->replace(edit_position, deletion_amount, ""));
ts_document_parse(doc);
ts_document_edit(doc, input->undo());
ts_document_parse(doc);
});
}
}
});
}