1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:17:44 +00:00

LibJS: Throw TypeError on write to non-writable property in strict mode

This commit is contained in:
Idan Horowitz 2021-06-06 00:43:03 +03:00 committed by Linus Groh
parent 31534055e4
commit 2a8f4f097c
3 changed files with 15 additions and 0 deletions

View file

@ -0,0 +1,12 @@
test("normal mode", () => {
expect(() => {
NaN = 5; // NaN is a non-writable global variable
}).not.toThrow();
});
test("strict mode", () => {
expect(() => {
"use strict";
NaN = 5; // NaN is a non-writable global variable
}).toThrowWithMessage(TypeError, "Cannot write to non-writable property 'NaN'");
});