fill out tests for more corner cases

This commit is contained in:
Allen Webster
2021-06-30 14:59:26 -04:00
parent 097541c9b7
commit 1bcd741eeb
2 changed files with 59 additions and 5 deletions
+4 -4
View File
@@ -3,12 +3,12 @@
// TODO List
//
// [ ] unify string literal token kinds
// [ ] simplify string literal flags (triple as a single flag)
// [x] unify string literal token kinds
// [x] simplify string literal flags (triple as a single flag)
// [ ] lexer detects broken comments
// [ ] lexer detects broken strings
// [ ] tests for legal tag syntaxes
// [ ] tests that ensure we don't accept labels when expecting symbols e.g. foo ":" b; foo: "(" )
// [x] tests for legal tag syntaxes
// [x] tests that ensure we don't accept labels when expecting symbols e.g. foo ":" b; foo: "(" )
// [ ] pass all tests
// [ ] simplify error sorting and catastrophic error handling
// [ ] integer -> string helpers
+55 -1
View File
@@ -745,6 +745,32 @@ int main(void)
}
}
Test("Tags")
{
MD_String8 file_name = MD_S8Lit("raw_text");
{
MD_ParseResult result = MD_ParseWholeString(file_name,
MD_S8Lit("@foo bar"));
TestResult(MD_NodeHasTag(result.node->first_child, MD_S8Lit("foo")));
}
{
MD_ParseResult result = MD_ParseWholeString(file_name,
MD_S8Lit("@+ bar"));
TestResult(MD_NodeHasTag(result.node->first_child, MD_S8Lit("+")));
}
{
MD_ParseResult result = MD_ParseWholeString(file_name,
MD_S8Lit("@'a b c' bar"));
TestResult(MD_NodeHasTag(result.node->first_child, MD_S8Lit("a b c")));
}
{
MD_ParseResult result = MD_ParseWholeString(file_name,
MD_S8Lit("@100 bar"));
TestResult(MD_NodeHasTag(result.node->first_child, MD_S8Lit("100")));
}
}
Test("Tagged & Unlabeled")
{
MD_String8 file_name = MD_S8Lit("raw_text");
@@ -858,7 +884,35 @@ int main(void)
}
}
MD_String8 str = MD_PushStringF("%i", "foobar");
Test("Labels are Not Reserved")
{
MD_String8 file_name = MD_S8Lit("raw_text");
{
MD_ParseResult result = MD_ParseWholeString(file_name,
MD_S8Lit("foo: '(' )"));
TestResult(result.errors.first != 0);
}
{
MD_ParseResult result = MD_ParseWholeString(file_name,
MD_S8Lit("foo ':' ( )"));
TestResult(result.errors.first == 0);
TestResult(MD_ChildCountFromNode(result.node) == 3);
}
{
MD_ParseResult result = MD_ParseWholeString(file_name,
MD_S8Lit("'@'bar foo"));
TestResult(result.errors.first == 0);
TestResult(MD_ChildCountFromNode(result.node) == 3);
}
{
MD_ParseResult result = MD_ParseWholeString(file_name,
MD_S8Lit("foo: '(' ')'"));
TestResult(result.errors.first == 0);
TestResult(MD_ChildCountFromNode(result.node) == 1);
TestResult(MD_ChildCountFromNode(result.node->first_child) == 2);
}
}
return 0;
}