1
0

test session id invalid fromStruct

This commit is contained in:
Adrian Wannenmacher 2026-02-15 04:37:52 +01:00
parent a27f3ac3af
commit 2a2472a052
Signed by: tfld
GPG Key ID: 19D986ECB1E492D5
2 changed files with 17 additions and 0 deletions

View File

@ -141,6 +141,9 @@ export default class Session {
if ("id" in value) { if ("id" in value) {
if (typeof value.id !== "number") if (typeof value.id !== "number")
throw new TypeError("if struct contains id, then it must be a number"); throw new TypeError("if struct contains id, then it must be a number");
if (!Number.isInteger(value.id))
throw new RangeError(
"if struct contains id, then it must be an integer");
this.id = value.id; this.id = value.id;
} }

View File

@ -208,6 +208,20 @@ export default function() {
finished.currentRound.raise(Team.We); finished.currentRound.raise(Team.We);
finished.currentRound.winner = Team.They; finished.currentRound.winner = Team.They;
struct.id = "nope";
doIt(
"string id",
new TypeError("if struct contains id, then it must be a number"));
struct.id = 1.1;
doIt(
"float id",
new RangeError("if struct contains id, then it must be an integer"));
struct.id = undefined;
doIt(
"undefined id",
new TypeError("if struct contains id, then it must be a number"));
delete struct.id;
doIt("no goal", new TypeError("struct must contain goal as number")); doIt("no goal", new TypeError("struct must contain goal as number"));
struct.goal = "3"; struct.goal = "3";
doIt("string goal", new TypeError("struct must contain goal as number")); doIt("string goal", new TypeError("struct must contain goal as number"));