chore: add test cases for choice statement parsing
This commit is contained in:
parent
7afc6719d9
commit
6f54e6fbcd
5 changed files with 85 additions and 64 deletions
|
|
@ -105,6 +105,91 @@ test "parser: temporary assignment" {
|
|||
);
|
||||
}
|
||||
|
||||
test "parser: choice statements, simple" {
|
||||
try testEqual(
|
||||
\\* A
|
||||
\\* B
|
||||
\\* C
|
||||
,
|
||||
\\File "<STDIN>"
|
||||
\\`--BlockStmt <line:1, line:3>
|
||||
\\ `--ChoiceStmt <line:1, line:3>
|
||||
\\ |--ChoiceStarStmt <line:1, col:1:4>
|
||||
\\ | `--ChoiceContentExpr <col:3, col:4>
|
||||
\\ | `--ChoiceStartContentExpr `A` <col:3, col:4>
|
||||
\\ |--ChoiceStarStmt <line:2, col:1:4>
|
||||
\\ | `--ChoiceContentExpr <col:3, col:4>
|
||||
\\ | `--ChoiceStartContentExpr `B` <col:3, col:4>
|
||||
\\ `--ChoiceStarStmt <line:3, col:1:4>
|
||||
\\ `--ChoiceContentExpr <col:3, col:4>
|
||||
\\ `--ChoiceStartContentExpr `C` <col:3, col:4>
|
||||
\\
|
||||
,
|
||||
);
|
||||
}
|
||||
|
||||
test "parser: choice statements, empty branch" {
|
||||
try testEqual(
|
||||
\\*
|
||||
,
|
||||
\\File "<STDIN>"
|
||||
\\`--BlockStmt <line:1, line:1>
|
||||
\\ `--ChoiceStmt <line:1, line:1>
|
||||
\\ `--ChoiceStarStmt <line:1, col:1:2>
|
||||
\\ `--ChoiceContentExpr <col:2, col:2>
|
||||
\\ `--EmptyString <col:2, col:2>
|
||||
\\
|
||||
,
|
||||
);
|
||||
}
|
||||
|
||||
test "parser: choice statements, level normalization" {
|
||||
try testEqual(
|
||||
\\***** A
|
||||
\\**** B
|
||||
\\*** C
|
||||
\\** D
|
||||
\\* E
|
||||
,
|
||||
\\File "<STDIN>"
|
||||
\\`--BlockStmt <line:1, line:5>
|
||||
\\ `--ChoiceStmt <line:1, line:5>
|
||||
\\ |--ChoiceStarStmt <line:1, col:1:8>
|
||||
\\ | `--ChoiceContentExpr <col:7, col:8>
|
||||
\\ | `--ChoiceStartContentExpr `A` <col:7, col:8>
|
||||
\\ |--ChoiceStarStmt <line:2, col:1:7>
|
||||
\\ | `--ChoiceContentExpr <col:6, col:7>
|
||||
\\ | `--ChoiceStartContentExpr `B` <col:6, col:7>
|
||||
\\ |--ChoiceStarStmt <line:3, col:1:6>
|
||||
\\ | `--ChoiceContentExpr <col:5, col:6>
|
||||
\\ | `--ChoiceStartContentExpr `C` <col:5, col:6>
|
||||
\\ |--ChoiceStarStmt <line:4, col:1:5>
|
||||
\\ | `--ChoiceContentExpr <col:4, col:5>
|
||||
\\ | `--ChoiceStartContentExpr `D` <col:4, col:5>
|
||||
\\ `--ChoiceStarStmt <line:5, col:1:4>
|
||||
\\ `--ChoiceContentExpr <col:3, col:4>
|
||||
\\ `--ChoiceStartContentExpr `E` <col:3, col:4>
|
||||
\\
|
||||
,
|
||||
);
|
||||
}
|
||||
|
||||
test "parser: choice statements, mixed context" {
|
||||
try testEqual(
|
||||
\\* A[]B
|
||||
,
|
||||
\\File "<STDIN>"
|
||||
\\`--BlockStmt <line:1, line:1>
|
||||
\\ `--ChoiceStmt <line:1, line:1>
|
||||
\\ `--ChoiceStarStmt <line:1, col:1:7>
|
||||
\\ `--ChoiceContentExpr <col:3, col:7>
|
||||
\\ |--ChoiceStartContentExpr `A` <col:3, col:4>
|
||||
\\ `--ChoiceInnerContentExpr `B` <col:6, col:7>
|
||||
\\
|
||||
,
|
||||
);
|
||||
}
|
||||
|
||||
test "parser: simple knot" {
|
||||
try testEqual(
|
||||
\\=== knot ===
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue