ladybird/Userland/Libraries/LibJS/Tests/strict-mode-errors.js
Shannon Booth d766014787 LibJS/Tests: Set failing bytecode tests as xfail when in bytecode mode
This should allow us to enable running test-js in bytecode mode in CI.
2023-07-23 07:36:13 +02:00

23 lines
882 B
JavaScript

"use strict";
test.xfailIf(isBytecodeInterpreterEnabled(), "basic functionality", () => {
[true, false, "foo", 123].forEach(primitive => {
expect(() => {
primitive.foo = "bar";
}).toThrowWithMessage(TypeError, `Cannot set property 'foo' of ${primitive}`);
expect(() => {
primitive[Symbol.hasInstance] = 123;
}).toThrowWithMessage(
TypeError,
`Cannot set property 'Symbol(Symbol.hasInstance)' of ${primitive}`
);
});
[null, undefined].forEach(primitive => {
expect(() => {
primitive.foo = "bar";
}).toThrowWithMessage(TypeError, `${primitive} cannot be converted to an object`);
expect(() => {
primitive[Symbol.hasInstance] = 123;
}).toThrowWithMessage(TypeError, `${primitive} cannot be converted to an object`);
});
});