Transfer commit
This commit is contained in:
parent
38de4a7419
commit
797e5ea192
30 changed files with 2393 additions and 395 deletions
|
|
@ -11,170 +11,136 @@ use rottlib::diagnostics::Diagnostic;
|
|||
use rottlib::lexer::TokenizedFile;
|
||||
use rottlib::parser::Parser;
|
||||
|
||||
const TEST_CASES: &[(&str, &str)] = &[
|
||||
// P0057 - VarEditorSpecifierExpected
|
||||
("files/P0057_01.uc", "var(Category,) int A;\n"),
|
||||
("files/P0057_02.uc", "var(,) int A;\n"),
|
||||
(
|
||||
"files/P0057_03.uc",
|
||||
"var(\n ,\n ,\n Category\n) int A;\n",
|
||||
),
|
||||
(
|
||||
"files/P0057_04.uc",
|
||||
"var(\n Category,\n\n\n) int A;\n",
|
||||
),
|
||||
|
||||
// P0058 - VarEditorSpecifierListMissingSeparator
|
||||
("files/P0058_01.uc", "var(Category DisplayName) int A;\n"),
|
||||
("files/P0058_02.uc", "var(\"Display\" \"Tooltip\") int A;\n"),
|
||||
(
|
||||
"files/P0058_03.uc",
|
||||
"var(\n Category\n DisplayName\n) int A;\n",
|
||||
),
|
||||
(
|
||||
"files/P0058_04.uc",
|
||||
"var(\n Category\n\n \"Display Name\",\n Advanced\n) int A;\n",
|
||||
),
|
||||
|
||||
// P0059 - VarEditorSpecifierListExpectedCommaOrClosingParenthesis
|
||||
("files/P0059_01.uc", "var(Category :) int A;\n"),
|
||||
("files/P0059_02.uc", "var(\"Display\" *) int A;\n"),
|
||||
(
|
||||
"files/P0059_03.uc",
|
||||
"var(\n Category\n [\n) int A;\n",
|
||||
),
|
||||
(
|
||||
"files/P0059_04.uc",
|
||||
"var(\n \"Display Name\"\n\n ]\n) int A;\n",
|
||||
),
|
||||
|
||||
// P0060 - VarEditorSpecifierListMissingClosingParenthesis
|
||||
("files/P0060_01.uc", "var(Category\n"),
|
||||
(
|
||||
"files/P0060_02.uc",
|
||||
"var(\n Category,\n \"Display Name\"\n",
|
||||
),
|
||||
(
|
||||
"files/P0060_03.uc",
|
||||
"var(\n\n\n",
|
||||
),
|
||||
(
|
||||
"files/P0060_04.uc",
|
||||
"var(\n Category,\n\n \"Display Name\"\n\n",
|
||||
),
|
||||
];
|
||||
|
||||
/// Lexer-focused fixtures.
|
||||
///
|
||||
/// Keep these small: the goal is to inspect lexer diagnostics and delimiter
|
||||
/// recovery behavior, not full parser behavior.
|
||||
const TEST_CASES: &[(&str, &str)] = &[
|
||||
// P0034 - SwitchMissingBody
|
||||
("files/P0034_01.uc", "switch(A) local\n"),
|
||||
("files/P0034_02.uc", "switch\n(A)\nvar"),
|
||||
("files/P0034_03.uc", "switch(\n A\n)\n"),
|
||||
("files/P0034_04.uc", "switch\n(\n A\n)\n"),
|
||||
("files/P0034_05.uc", "switch(A)\ncase 1:\n"),
|
||||
|
||||
// P0035 - SwitchTopLevelItemNotCase
|
||||
("files/P0035_01.uc", "switch(A) {\n Log(\"bad\");\n}\n"),
|
||||
/*const TEST_CASES: &[(&str, &str)] = &[
|
||||
// P0061 - TypeSpecifierExpected
|
||||
("files/P0061_01.uc", "{\n local ;\n}\n"),
|
||||
(
|
||||
"files/P0035_02.uc",
|
||||
"switch\n(A)\n{\n Log(\"bad\");\n Log(\"worse\");\n case 1:\n}\n",
|
||||
),
|
||||
("files/P0035_03.uc", "switch(A) {\n 123;\n default:\n}\n"),
|
||||
(
|
||||
"files/P0035_04.uc",
|
||||
"switch\n(\n A\n)\n{\n if (A) {}\n case 1:\n}\n",
|
||||
"files/P0061_02.uc",
|
||||
"{\n local\n ;\n}\n",
|
||||
),
|
||||
(
|
||||
"files/P0035_05.uc",
|
||||
"switch(A) {\n {\n Log(\"nested\");\n }\n case 1:\n}\n",
|
||||
"files/P0061_03.uc",
|
||||
"{\n local\n [\n ] Values;\n}\n",
|
||||
),
|
||||
(
|
||||
"files/P0061_04.uc",
|
||||
"{\n local\n",
|
||||
),
|
||||
|
||||
// P0036 - SwitchCaseMissingColon
|
||||
// P0062 - NamedTypeInvalidName
|
||||
("files/P0062_01.uc", "{\n local Foo. ;\n}\n"),
|
||||
(
|
||||
"files/P0036_01.uc",
|
||||
"switch(A) {\n case 1\n case 2:\n}\n",
|
||||
"files/P0062_02.uc",
|
||||
"{\n local\n Foo.\n ;\n}\n",
|
||||
),
|
||||
(
|
||||
"files/P0036_02.uc",
|
||||
"switch\n(A)\n{\n case\n 1\n default:\n}\n",
|
||||
"files/P0062_03.uc",
|
||||
"{\n local Foo..Bar Value;\n}\n",
|
||||
),
|
||||
(
|
||||
"files/P0036_03.uc",
|
||||
"switch(A) {\n case (A)\n case B:\n}\n",
|
||||
),
|
||||
(
|
||||
"files/P0036_04.uc",
|
||||
"switch\n(\n A\n)\n{\n case\n A + B\n default\n :\n}\n",
|
||||
),
|
||||
(
|
||||
"files/P0036_05.uc",
|
||||
"switch(A) {\n case Foo.Bar(Baz)\n case Other:\n}\n",
|
||||
"files/P0062_04.uc",
|
||||
"{\n local\n SomePackage\n .\n",
|
||||
),
|
||||
|
||||
// P0037 - SwitchDefaultMissingColon
|
||||
// P0063 - ArrayTypeMissingOpeningAngleBracket
|
||||
("files/P0063_01.uc", "{\n local array Values;\n}\n"),
|
||||
(
|
||||
"files/P0037_01.uc",
|
||||
"switch(A) {\n default\n if (A) {}\n}\n",
|
||||
"files/P0063_02.uc",
|
||||
"{\n local\n array\n Values;\n}\n",
|
||||
),
|
||||
("files/P0063_03.uc", "{\n local array[] Values;\n}\n"),
|
||||
(
|
||||
"files/P0037_02.uc",
|
||||
"switch\n(A)\n{\n default\n while (A) {}\n}\n",
|
||||
),
|
||||
(
|
||||
"files/P0037_03.uc",
|
||||
"switch(A) {\n default\n for (;;) {}\n}\n",
|
||||
),
|
||||
(
|
||||
"files/P0037_04.uc",
|
||||
"switch\n(\n A\n)\n{\n default\n switch(B) {\n case 1:\n }\n}\n",
|
||||
),
|
||||
(
|
||||
"files/P0037_05.uc",
|
||||
"switch(A) {\n default\n case 1:\n}\n",
|
||||
"files/P0063_04.uc",
|
||||
"{\n local\n array",
|
||||
),
|
||||
|
||||
// P0038 - SwitchDuplicateDefault
|
||||
// P0064 - ArrayTypeMissingClosingAngleBracket
|
||||
("files/P0064_01.uc", "{\n local array<int Values;\n}\n"),
|
||||
(
|
||||
"files/P0038_01.uc",
|
||||
"switch(A) {\n default:\n default:\n}\n",
|
||||
"files/P0064_02.uc",
|
||||
"{\n local\n array<\n int\n Values;\n}\n",
|
||||
),
|
||||
(
|
||||
"files/P0038_02.uc",
|
||||
"switch\n(A)\n{\n default\n :\n default\n :\n}\n",
|
||||
"files/P0064_03.uc",
|
||||
"{\n local array<class<Actor> ActorClasses;\n}\n",
|
||||
),
|
||||
(
|
||||
"files/P0038_03.uc",
|
||||
"switch(A) {\n default:\n default:\n default:\n}\n",
|
||||
),
|
||||
(
|
||||
"files/P0038_04.uc",
|
||||
"switch\n(\n A\n)\n{\n default:\n Log(\"first\");\n default:\n Log(\"second\");\n}\n",
|
||||
"files/P0064_04.uc",
|
||||
"{\n local\n array<\n string",
|
||||
),
|
||||
|
||||
// P0039 - SwitchCasesAfterDefault
|
||||
// P0065 - ArrayTypeMissingElementType
|
||||
("files/P0065_01.uc", "{\n local array<> Values;\n}\n"),
|
||||
(
|
||||
"files/P0039_01.uc",
|
||||
"switch(A) {\n default:\n case 1:\n}\n",
|
||||
"files/P0065_02.uc",
|
||||
"{\n local\n array<>\n Values;\n}\n",
|
||||
),
|
||||
(
|
||||
"files/P0039_02.uc",
|
||||
"switch\n(A)\n{\n default\n :\n case\n 1\n :\n}\n",
|
||||
"files/P0065_03.uc",
|
||||
"{\n local array<\n > Values;\n}\n",
|
||||
),
|
||||
(
|
||||
"files/P0039_03.uc",
|
||||
"switch(A) {\n default:\n case 1:\n case 2:\n}\n",
|
||||
"files/P0065_04.uc",
|
||||
"{\n local array<array<> > NestedValues;\n}\n",
|
||||
),
|
||||
(
|
||||
"files/P0039_04.uc",
|
||||
"switch\n(\n A\n)\n{\n default:\n case 1:\n Log(\"one\");\n case 2:\n Log(\"two\");\n}\n",
|
||||
),
|
||||
(
|
||||
"files/P0039_05.uc",
|
||||
"switch(A) {\n default:\n Log(\"done\");\n case 1:\n case 2:\n Log(\"stacked\");\n}\n",
|
||||
),
|
||||
|
||||
// P0040 - SwitchMissingClosingBrace
|
||||
("files/P0040_01.uc", "switch(A) {\n"),
|
||||
("files/P0040_02.uc", "switch(A) {\n case 1:\n"),
|
||||
("files/P0040_03.uc", "switch\n(A)\n{\n default:\n"),
|
||||
(
|
||||
"files/P0040_04.uc",
|
||||
"switch\n(\n A\n)\n{\n case 1:\n case 2:\n",
|
||||
),
|
||||
(
|
||||
"files/P0040_05.uc",
|
||||
"switch(A) {\n case 1:\n Log(\"body\");\n",
|
||||
),
|
||||
|
||||
// P0041 - SwitchCaseMissingExpression
|
||||
("files/P0041_01.uc", "switch(A) {\n case:\n}\n"),
|
||||
("files/P0041_02.uc", "switch\n(A)\n{\n case\n :\n}\n"),
|
||||
("files/P0041_03.uc", "switch(A) {\n case:\n default:\n}\n"),
|
||||
(
|
||||
"files/P0041_04.uc",
|
||||
"switch\n(\n A\n)\n{\n case\n :\n case 1:\n}\n",
|
||||
),
|
||||
(
|
||||
"files/P0041_05.uc",
|
||||
"switch(A) {\n case\n :\n default:\n}\n",
|
||||
),
|
||||
|
||||
// P0042 - SwitchCaseExpressionInvalidStart
|
||||
("files/P0042_01.uc", "switch(A) {\n case *:\n}\n"),
|
||||
(
|
||||
"files/P0042_02.uc",
|
||||
"switch\n(A)\n{\n case\n =\n :\n}\n",
|
||||
),
|
||||
("files/P0042_03.uc", "switch(A) {\n case &&:\n default:\n}\n"),
|
||||
(
|
||||
"files/P0042_04.uc",
|
||||
"switch\n(\n A\n)\n{\n case\n .\n :\n case 1:\n}\n",
|
||||
),
|
||||
(
|
||||
"files/P0042_05.uc",
|
||||
"switch(A) {\n case ]:\n}\n",
|
||||
),
|
||||
|
||||
// Mixed / intentional cascades
|
||||
(
|
||||
"files/P0042_cascade_01.uc",
|
||||
"switch(A) {\n case *\n case 1:\n}\n",
|
||||
),
|
||||
(
|
||||
"files/P0042_cascade_02.uc",
|
||||
"switch\n(\n A\n)\n{\n case\n =\n default:\n}\n",
|
||||
),
|
||||
];
|
||||
];*/
|
||||
|
||||
/// If true, also run the parser after tokenization.
|
||||
///
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue