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
commit 2a8f4f097c
Notes: sideshowbarker 2024-07-18 15:40:57 +09:00
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'");
});