LibJS: Remove bytecode condition from tests expected to fail

This commit is contained in:
Timothy Flynn 2023-08-09 15:14:05 -04:00 committed by Luke Wilde
parent 854330ec73
commit 375a6f5dd9
17 changed files with 143 additions and 186 deletions

View file

@ -7,7 +7,7 @@ test("is the same as dispose", () => {
});
describe("used in using functionality", () => {
test.xfailIf(isBytecodeInterpreterEnabled(), "make the stack marked as disposed", () => {
test.xfail("make the stack marked as disposed", () => {
let innerStack;
{
using stack = new DisposableStack();

View file

@ -3,7 +3,7 @@ const stackGetter = stackDescriptor.get;
const stackSetter = stackDescriptor.set;
describe("getter - normal behavior", () => {
test.xfailIf(isBytecodeInterpreterEnabled(), "basic functionality", () => {
test.xfail("basic functionality", () => {
const stackFrames = [
/^ at .*Error \(.*\/Error\.prototype\.stack\.js:\d+:\d+\)$/,
/^ at .+\/Error\/Error\.prototype\.stack\.js:\d+:\d+$/,

View file

@ -8,7 +8,7 @@ function registerInDifferentScope(registry) {
return target;
}
test.xfailIf(isBytecodeInterpreterEnabled(), "basic functionality", () => {
test.xfail("basic functionality", () => {
var registry = new FinalizationRegistry(() => {});
var count = 0;

View file

@ -40,7 +40,7 @@ describe("normal behavior", () => {
expect(passed).toBeTrue();
});
test.xfailIf(isBytecodeInterpreterEnabled(), "value from async module", () => {
test.xfail("value from async module", () => {
const shadowRealm = new ShadowRealm();
const promise = shadowRealm.importValue("./async-module.mjs", "foo");
expect(promise).toBeInstanceOf(Promise);

View file

@ -21,29 +21,25 @@ test("invalid values", () => {
});
});
test.xfailIf(
isBytecodeInterpreterEnabled(),
"automatic removal of garbage-collected values",
() => {
const weakMap = new WeakMap();
const objectKey = { e: 3 };
test.xfail("automatic removal of garbage-collected values", () => {
const weakMap = new WeakMap();
const objectKey = { e: 3 };
expect(weakMap.set(objectKey, 1)).toBe(weakMap);
expect(getWeakMapSize(weakMap)).toBe(1);
expect(weakMap.set(objectKey, 1)).toBe(weakMap);
expect(getWeakMapSize(weakMap)).toBe(1);
markAsGarbage("objectKey");
gc();
markAsGarbage("objectKey");
gc();
expect(getWeakMapSize(weakMap)).toBe(0);
expect(getWeakMapSize(weakMap)).toBe(0);
const symbolKey = Symbol("foo");
const symbolKey = Symbol("foo");
expect(weakMap.set(symbolKey, "bar")).toBe(weakMap);
expect(getWeakMapSize(weakMap)).toBe(1);
expect(weakMap.set(symbolKey, "bar")).toBe(weakMap);
expect(getWeakMapSize(weakMap)).toBe(1);
markAsGarbage("symbolKey");
gc();
markAsGarbage("symbolKey");
gc();
expect(getWeakMapSize(weakMap)).toBe(0);
}
);
expect(getWeakMapSize(weakMap)).toBe(0);
});

View file

@ -16,29 +16,25 @@ test("invalid values", () => {
});
});
test.xfailIf(
isBytecodeInterpreterEnabled(),
"automatic removal of garbage-collected values",
() => {
const weakSet = new WeakSet();
const objectItem = { a: 1 };
test.xfail("automatic removal of garbage-collected values", () => {
const weakSet = new WeakSet();
const objectItem = { a: 1 };
expect(weakSet.add(objectItem)).toBe(weakSet);
expect(getWeakSetSize(weakSet)).toBe(1);
expect(weakSet.add(objectItem)).toBe(weakSet);
expect(getWeakSetSize(weakSet)).toBe(1);
markAsGarbage("objectItem");
gc();
markAsGarbage("objectItem");
gc();
expect(getWeakSetSize(weakSet)).toBe(0);
expect(getWeakSetSize(weakSet)).toBe(0);
const symbolItem = Symbol("foo");
const symbolItem = Symbol("foo");
expect(weakSet.add(symbolItem)).toBe(weakSet);
expect(getWeakSetSize(weakSet)).toBe(1);
expect(weakSet.add(symbolItem)).toBe(weakSet);
expect(getWeakSetSize(weakSet)).toBe(1);
markAsGarbage("symbolItem");
gc();
markAsGarbage("symbolItem");
gc();
expect(getWeakSetSize(weakSet)).toBe(0);
}
);
expect(getWeakSetSize(weakSet)).toBe(0);
});

View file

@ -1,4 +1,4 @@
test.xfailIf(isBytecodeInterpreterEnabled(), "assignment to function call", () => {
test.xfail("assignment to function call", () => {
expect(() => {
function foo() {}
foo() = "foo";
@ -9,7 +9,7 @@ test("assignment to function call in strict mode", () => {
expect("'use strict'; foo() = 'foo'").toEval();
});
test.xfailIf(isBytecodeInterpreterEnabled(), "assignment to inline function call", () => {
test.xfail("assignment to inline function call", () => {
expect(() => {
(function () {})() = "foo";
}).toThrowWithMessage(ReferenceError, "Invalid left-hand side in assignment");

View file

@ -86,39 +86,28 @@ describe("special left hand sides", () => {
expect(b.a).toBe("2");
});
test.xfailIf(
isBytecodeInterpreterEnabled(),
"call function is allowed in parsing but fails in runtime",
() => {
function f() {
expect().fail();
}
// Does not fail since it does not iterate
expect("for (f() in []);").toEvalTo(undefined);
expect(() => {
eval("for (f() in [0]) { expect().fail() }");
}).toThrowWithMessage(ReferenceError, "Invalid left-hand side in assignment");
test.xfail("call function is allowed in parsing but fails in runtime", () => {
function f() {
expect().fail();
}
);
test.xfailIf(
isBytecodeInterpreterEnabled(),
"Cannot change constant declaration in body",
() => {
const vals = [];
for (const v in [1, 2]) {
expect(() => v++).toThrowWithMessage(
TypeError,
"Invalid assignment to const variable"
);
vals.push(v);
}
// Does not fail since it does not iterate
expect("for (f() in []);").toEvalTo(undefined);
expect(vals).toEqual(["0", "1"]);
expect(() => {
eval("for (f() in [0]) { expect().fail() }");
}).toThrowWithMessage(ReferenceError, "Invalid left-hand side in assignment");
});
test.xfail("Cannot change constant declaration in body", () => {
const vals = [];
for (const v in [1, 2]) {
expect(() => v++).toThrowWithMessage(TypeError, "Invalid assignment to const variable");
vals.push(v);
}
);
expect(vals).toEqual(["0", "1"]);
});
});
test("remove properties while iterating", () => {

View file

@ -130,37 +130,26 @@ describe("special left hand sides", () => {
expect(f().a).toBe("c");
});
test.xfailIf(
isBytecodeInterpreterEnabled(),
"call function is allowed in parsing but fails in runtime",
() => {
function f() {
expect().fail();
}
// Does not fail since it does not iterate but prettier does not like it so we use eval.
expect("for (f() of []);").toEvalTo(undefined);
expect(() => {
eval("for (f() of [0]) { expect().fail() }");
}).toThrowWithMessage(ReferenceError, "Invalid left-hand side in assignment");
test.xfail("call function is allowed in parsing but fails in runtime", () => {
function f() {
expect().fail();
}
);
test.xfailIf(
isBytecodeInterpreterEnabled(),
"Cannot change constant declaration in body",
() => {
const vals = [];
for (const v of [1, 2]) {
expect(() => v++).toThrowWithMessage(
TypeError,
"Invalid assignment to const variable"
);
vals.push(v);
}
// Does not fail since it does not iterate but prettier does not like it so we use eval.
expect("for (f() of []);").toEvalTo(undefined);
expect(vals).toEqual([1, 2]);
expect(() => {
eval("for (f() of [0]) { expect().fail() }");
}).toThrowWithMessage(ReferenceError, "Invalid left-hand side in assignment");
});
test.xfail("Cannot change constant declaration in body", () => {
const vals = [];
for (const v of [1, 2]) {
expect(() => v++).toThrowWithMessage(TypeError, "Invalid assignment to const variable");
vals.push(v);
}
);
expect(vals).toEqual([1, 2]);
});
});

View file

@ -207,8 +207,7 @@ describe("in- and exports", () => {
expectModulePassed("./anon-func-decl-default-export.mjs");
});
test.xfailIf(
isBytecodeInterpreterEnabled(),
test.xfail(
"can have top level using declarations which trigger at the end of running a module",
() => {
expectModulePassed("./top-level-dispose.mjs");

View file

@ -221,13 +221,13 @@ describe("naming of anon functions", () => {
expect({ func() {} }.func.name).toBe("func");
});
test.xfailIf(isBytecodeInterpreterEnabled(), "getter has name", () => {
test.xfail("getter has name", () => {
expect(Object.getOwnPropertyDescriptor({ get func() {} }, "func").get.name).toBe(
"get func"
);
});
test.xfailIf(isBytecodeInterpreterEnabled(), "setter has name", () => {
test.xfail("setter has name", () => {
expect(Object.getOwnPropertyDescriptor({ set func(v) {} }, "func").set.name).toBe(
"set func"
);

View file

@ -144,7 +144,7 @@ describe("modification of spreadable objects during spread", () => {
expect(Object.getOwnPropertyNames(result)).toContain("bar");
});
test.xfailIf(isBytecodeInterpreterEnabled(), "spreading array", () => {
test.xfail("spreading array", () => {
const array = [0];
array[2] = 2;
array[999] = 999;

View file

@ -1,6 +1,6 @@
"use strict";
test.xfailIf(isBytecodeInterpreterEnabled(), "basic functionality", () => {
test.xfail("basic functionality", () => {
[true, false, "foo", 123].forEach(primitive => {
expect(() => {
primitive.foo = "bar";

View file

@ -64,7 +64,7 @@ test("async function cannot use await in default parameters", () => {
// Even as a reference to some variable it is not allowed
expect(`
var await = 4;
async function foo(x = await) {}
async function foo(x = await) {}
`).not.toEval();
});
@ -216,55 +216,43 @@ describe("await thenables", () => {
expect(isCalled).toBe(true);
});
test.xfailIf(
isBytecodeInterpreterEnabled(),
"async returning a thanable variable that fulfills",
() => {
let isCalled = false;
const obj = {
then(fulfill) {
isCalled = true;
fulfill(isCalled);
},
};
test.xfail("async returning a thanable variable that fulfills", () => {
let isCalled = false;
const obj = {
then(fulfill) {
isCalled = true;
fulfill(isCalled);
},
};
const f = async () => await obj;
f();
runQueuedPromiseJobs();
expect(isCalled).toBe(true);
}
);
const f = async () => await obj;
f();
runQueuedPromiseJobs();
expect(isCalled).toBe(true);
});
test.xfailIf(
isBytecodeInterpreterEnabled(),
"async returning a thenable directly without fulfilling",
() => {
let isCalled = false;
const f = async () => ({
then() {
isCalled = true;
},
});
f();
runQueuedPromiseJobs();
expect(isCalled).toBe(true);
}
);
test.xfail("async returning a thenable directly without fulfilling", () => {
let isCalled = false;
const f = async () => ({
then() {
isCalled = true;
},
});
f();
runQueuedPromiseJobs();
expect(isCalled).toBe(true);
});
test.xfailIf(
isBytecodeInterpreterEnabled(),
"async returning a thenable directly that fulfills",
() => {
let isCalled = false;
const f = async () => ({
then(fulfill) {
isCalled = true;
fulfill(isCalled);
},
});
f();
runQueuedPromiseJobs();
expect(isCalled).toBe(true);
}
);
test.xfail("async returning a thenable directly that fulfills", () => {
let isCalled = false;
const f = async () => ({
then(fulfill) {
isCalled = true;
fulfill(isCalled);
},
});
f();
runQueuedPromiseJobs();
expect(isCalled).toBe(true);
});
});

View file

@ -154,7 +154,7 @@ describe("tagged template literal functionality", () => {
expect(stringsValue.raw[1]).toBe("invalid\\u");
});
test.xfailIf(isBytecodeInterpreterEnabled(), "string value gets cached per AST node", () => {
test.xfail("string value gets cached per AST node", () => {
function call(func, val) {
return func`template${val}second`;
}
@ -164,7 +164,7 @@ describe("tagged template literal functionality", () => {
expect(firstResult).toBe(secondResult);
});
test.xfailIf(isBytecodeInterpreterEnabled(), "this value of call comes from reference", () => {
test.xfail("this value of call comes from reference", () => {
let thisValue = null;
const obj = {
func() {

View file

@ -1,5 +1,5 @@
describe("basic usage", () => {
test.xfailIf(isBytecodeInterpreterEnabled(), "disposes after block exit", () => {
test.xfail("disposes after block exit", () => {
let disposed = false;
let inBlock = false;
{
@ -13,7 +13,7 @@ describe("basic usage", () => {
expect(disposed).toBeTrue();
});
test.xfailIf(isBytecodeInterpreterEnabled(), "disposes in reverse order after block exit", () => {
test.xfail("disposes in reverse order after block exit", () => {
const disposed = [];
{
expect(disposed).toHaveLength(0);
@ -25,7 +25,7 @@ describe("basic usage", () => {
expect(disposed).toEqual(['b', 'a']);
});
test.xfailIf(isBytecodeInterpreterEnabled(), "disposes in reverse order after block exit even in same declaration", () => {
test.xfail("disposes in reverse order after block exit even in same declaration", () => {
const disposed = [];
{
expect(disposed).toHaveLength(0);
@ -41,7 +41,7 @@ describe("basic usage", () => {
describe("behavior with exceptions", () => {
function ExpectedError(name) { this.name = name; }
test.xfailIf(isBytecodeInterpreterEnabled(), "is run even after throw", () => {
test.xfail("is run even after throw", () => {
let disposed = false;
let inBlock = false;
let inCatch = false;
@ -62,7 +62,7 @@ describe("behavior with exceptions", () => {
expect(inCatch).toBeTrue();
});
test.xfailIf(isBytecodeInterpreterEnabled(), "throws error if dispose method does", () => {
test.xfail("throws error if dispose method does", () => {
let disposed = false;
let endOfTry = false;
let inCatch = false;
@ -84,7 +84,7 @@ describe("behavior with exceptions", () => {
expect(inCatch).toBeTrue();
});
test.xfailIf(isBytecodeInterpreterEnabled(), "if block and using throw get suppressed error", () => {
test.xfail("if block and using throw get suppressed error", () => {
let disposed = false;
let inCatch = false;
try {
@ -108,7 +108,7 @@ describe("behavior with exceptions", () => {
expect(inCatch).toBeTrue();
});
test.xfailIf(isBytecodeInterpreterEnabled(), "multiple throwing disposes give suppressed error", () => {
test.xfail("multiple throwing disposes give suppressed error", () => {
let inCatch = false;
try {
{
@ -133,7 +133,7 @@ describe("behavior with exceptions", () => {
expect(inCatch).toBeTrue();
});
test.xfailIf(isBytecodeInterpreterEnabled(), "3 throwing disposes give chaining suppressed error", () => {
test.xfail("3 throwing disposes give chaining suppressed error", () => {
let inCatch = false;
try {
{
@ -168,7 +168,7 @@ describe("behavior with exceptions", () => {
expect(inCatch).toBeTrue();
});
test.xfailIf(isBytecodeInterpreterEnabled(), "normal error and multiple disposing erorrs give chaining suppressed errors", () => {
test.xfail("normal error and multiple disposing erorrs give chaining suppressed errors", () => {
let inCatch = false;
try {
using a = { [Symbol.dispose]() {
@ -199,7 +199,7 @@ describe("behavior with exceptions", () => {
});
describe("works in a bunch of scopes", () => {
test.xfailIf(isBytecodeInterpreterEnabled(), "works in block", () => {
test.xfail("works in block", () => {
let dispose = false;
expect(dispose).toBeFalse();
{
@ -210,7 +210,7 @@ describe("works in a bunch of scopes", () => {
expect(dispose).toBeTrue();
});
test.xfailIf(isBytecodeInterpreterEnabled(), "works in static class block", () => {
test.xfail("works in static class block", () => {
let dispose = false;
expect(dispose).toBeFalse();
class A {
@ -223,7 +223,7 @@ describe("works in a bunch of scopes", () => {
expect(dispose).toBeTrue();
});
test.xfailIf(isBytecodeInterpreterEnabled(), "works in function", () => {
test.xfail("works in function", () => {
let dispose = [];
function f(val) {
const disposeLength = dispose.length;
@ -237,7 +237,7 @@ describe("works in a bunch of scopes", () => {
expect(dispose).toEqual([0, 1]);
});
test.xfailIf(isBytecodeInterpreterEnabled(), "switch block is treated as full block in function", () => {
test.xfail("switch block is treated as full block in function", () => {
let disposeFull = [];
let disposeInner = false;
@ -284,13 +284,13 @@ describe("works in a bunch of scopes", () => {
});
describe("invalid using bindings", () => {
test.xfailIf(isBytecodeInterpreterEnabled(), "nullish values do not throw", () => {
test.xfail("nullish values do not throw", () => {
using a = null, b = undefined;
expect(a).toBeNull();
expect(b).toBeUndefined();
});
test.xfailIf(isBytecodeInterpreterEnabled(), "non-object throws", () => {
test.xfail("non-object throws", () => {
[0, "a", true, NaN, 4n, Symbol.dispose].forEach(value => {
expect(() => {
using v = value;
@ -298,13 +298,13 @@ describe("invalid using bindings", () => {
});
});
test.xfailIf(isBytecodeInterpreterEnabled(), "object without dispose throws", () => {
test.xfail("object without dispose throws", () => {
expect(() => {
using a = {};
}).toThrowWithMessage(TypeError, "does not have dispose method");
});
test.xfailIf(isBytecodeInterpreterEnabled(), "object with non callable dispose throws", () => {
test.xfail("object with non callable dispose throws", () => {
[0, "a", true, NaN, 4n, Symbol.dispose, [], {}].forEach(value => {
expect(() => {
using a = { [Symbol.dispose]: value };
@ -332,7 +332,7 @@ describe("using is still a valid variable name", () => {
expect(using).toBe(1);
});
test.xfailIf(isBytecodeInterpreterEnabled(), "using", () => {
test.xfail("using", () => {
"use strict";
using using = null;
expect(using).toBeNull();

View file

@ -1,5 +1,5 @@
describe("basic usage", () => {
test.xfailIf(isBytecodeInterpreterEnabled(), "using in normal for loop", () => {
test.xfail("using in normal for loop", () => {
let isDisposed = false;
let lastI = -1;
for (
@ -27,7 +27,7 @@ describe("basic usage", () => {
expect(lastI).toBe(2);
});
test.xfailIf(isBytecodeInterpreterEnabled(), "using in normal for loop with expression body", () => {
test.xfail("using in normal for loop with expression body", () => {
let isDisposed = false;
let outerI = 0;
for (
@ -53,7 +53,7 @@ describe("basic usage", () => {
expect(outerI).toBe(3);
});
test.xfailIf(isBytecodeInterpreterEnabled(), "using in for of loop", () => {
test.xfail("using in for of loop", () => {
const disposable = [];
const values = [];
@ -75,7 +75,7 @@ describe("basic usage", () => {
expect(disposable).toEqual(['a', 'b', 'c']);
});
test.xfailIf(isBytecodeInterpreterEnabled(), "using in for of loop with expression body", () => {
test.xfail("using in for of loop with expression body", () => {
let disposableCalls = 0;
let i = 0;
@ -91,7 +91,7 @@ describe("basic usage", () => {
expect(disposableCalls).toBe(3);
});
test.xfailIf(isBytecodeInterpreterEnabled(), "can have multiple declaration in normal for loop", () => {
test.xfail("can have multiple declaration in normal for loop", () => {
let disposed = 0;
const a = {
[Symbol.dispose]() {
@ -106,7 +106,7 @@ describe("basic usage", () => {
expect(disposed).toBe(2);
});
test.xfailIf(isBytecodeInterpreterEnabled(), "can have using in block in for loop", () => {
test.xfail("can have using in block in for loop", () => {
const disposed = [];
const values = [];
for (let i = 0; i < 3; i++) {
@ -123,7 +123,7 @@ describe("basic usage", () => {
expect(disposed).toEqual([0, 1, 2]);
});
test.xfailIf(isBytecodeInterpreterEnabled(), "can have using in block in for-in loop", () => {
test.xfail("can have using in block in for-in loop", () => {
const disposed = [];
const values = [];
for (const i in ['a', 'b', 'c']) {
@ -140,7 +140,7 @@ describe("basic usage", () => {
expect(disposed).toEqual(["0", "1", "2"]);
});
test.xfailIf(isBytecodeInterpreterEnabled(), "dispose is called even if throw in for of loop", () => {
test.xfail("dispose is called even if throw in for of loop", () => {
let disposableCalls = 0;
const obj = {
@ -209,7 +209,7 @@ describe("using is still a valid variable in loops", () => {
expect(enteredLoop).toBeTrue();
});
test.xfailIf(isBytecodeInterpreterEnabled(), "using using of", () => {
test.xfail("using using of", () => {
let enteredLoop = false;
for (using using of [null]) {
enteredLoop = true;