fix(coords): Chunk-Namen korrekt für Float-Indizes und Newlines

- chunk_name: Reject float/bool indices like JavaScript (Number.isInteger)
- parse_chunk_name: Use fullmatch instead of match($) to reject strings with trailing newlines
- Add invalidIndices fixture cases to catch these edge cases in both languages

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
knsoandClaude Haiku 4.5 committed 2026-09-13 09:49:53 +02:00
1 parent 2f63779363
commit f0f7692f14
4 files changed
+20 -4

No files matched your search

+6
View File
@@ -49,6 +49,12 @@ describe("Chunk-Namen", () => {
expect(chunkName(1.5, 3)).toBeNull();
});
it("lehnt ungültige Indextypen ab", () => {
for (const [i, j] of NAMES.invalidIndices) {
expect(chunkName(i, j)).toBeNull();
}
});
it("kommt für alle 144 Chunks hin und zurück", () => {
for (let i = 0; i < 12; i++) {
for (let j = 0; j < 12; j++) expect(parseChunkName(chunkName(i, j))).toEqual({ i, j });
+2 -1
View File
@@ -1,5 +1,6 @@
{
"pairs": [["A1", 0, 0], ["L1", 11, 0], ["A12", 0, 11], ["L12", 11, 11], ["C10", 2, 9]],
"lowercase": [["c10", 2, 9], ["l12", 11, 11]],
"invalid": ["M1", "A0", "A13", "A", "10", "", "A01", "B-3", " "]
"invalid": ["M1", "A0", "A13", "A", "10", "", "A01", "B-3", " ", "A1\n"],
"invalidIndices": [[1.5, 3], [3, 2.5], [true, 0], [0, false]]
}