chore: add more error test cases for duplicate identifiers

This commit is contained in:
Brett Broadhurst 2026-03-26 08:30:36 -06:00
parent cd94a43cc9
commit 8fa228a9c2
Failed to generate hash of commit

View file

@ -14,7 +14,7 @@ test "compiler: unknown global variable" {
);
}
test "compiler: global variable shadowing" {
test "compiler: duplicate variable declarations" {
try testEqual(
\\VAR a = 0
\\VAR b = 2
@ -28,6 +28,33 @@ test "compiler: global variable shadowing" {
);
}
test "compiler: duplicate knot declarations" {
try testEqual(
\\== a
\\== a
,
\\<STDIN>:2:1: error: duplicate identifier
\\2 | == a
\\ | ^
\\
,
);
}
test "compiler: duplicate mixed declarations" {
try testEqual(
\\VAR a = 1
\\== a
\\Hello, world!
,
\\<STDIN>:1:1: error: duplicate identifier
\\1 | VAR a = 1
\\ | ^
\\
,
);
}
test "compiler: invalid divert target" {
try testEqual(
\\-> foo