ladybird/Libraries/LibJS/Tests/strict-mode-errors.js
Linus Groh 5a307836c1 LibJS: Handle symbol PropertyName in primitive assignment error
We can't just to_string() the PropertyName, it might be a symbol.
Instead to_value() it and then use to_string_without_side_effects() as
usual.

Fixes #4062.
2020-11-12 11:40:29 +01:00

12 lines
451 B
JavaScript

"use strict";
test("basic functionality", () => {
[true, false, "foo", 123].forEach(primitive => {
expect(() => {
primitive.foo = "bar";
}).toThrowWithMessage(TypeError, "Cannot assign property foo to primitive value");
expect(() => {
primitive[Symbol.hasInstance] = 123;
}).toThrowWithMessage(TypeError, "Cannot assign property Symbol(Symbol.hasInstance) to primitive value");
});
});