Replace assertThrowsInstanceOf with assert.throws in sm/expressions

This commit is contained in:
André Bargull 2025-04-30 14:15:52 +02:00 committed by Philip Chimento
parent a43514eb2d
commit 5b8828c4f8
6 changed files with 45 additions and 47 deletions

View File

@ -14,8 +14,6 @@ var summary = "Array destructuring with accessing uninitialized lexical binding.
print(BUGNUMBER + ": " + summary); print(BUGNUMBER + ": " + summary);
assertThrowsInstanceOf(() => { let y = [y] = []; }, assert.throws(ReferenceError, () => { let y = [y] = []; });
ReferenceError); assert.throws(ReferenceError, () => { let y = [y] = [,]; });
assertThrowsInstanceOf(() => { let y = [y] = [,]; },
ReferenceError);

View File

@ -20,8 +20,8 @@ function assertNoError(f, msg) {
} }
function assertSyntaxError(code) { function assertSyntaxError(code) {
assertThrowsInstanceOf(function () { Function(code); }, SyntaxError, "Function:" + code); assert.throws(SyntaxError, function () { Function(code); }, "Function:" + code);
assertThrowsInstanceOf(function () { AsyncFunction(code); }, SyntaxError, "AsyncFunction:" + code); assert.throws(SyntaxError, function () { AsyncFunction(code); }, "AsyncFunction:" + code);
} }
function assertNoSyntaxError(code) { function assertNoSyntaxError(code) {

View File

@ -21,21 +21,21 @@ assert.throws(TypeError, () => 'this is subString' in 'this is base');
assert.throws(TypeError, () => 'HEAD' + 'subString'.repeat(30000) in 'HEAD' + 'base'.repeat(30000)); assert.throws(TypeError, () => 'HEAD' + 'subString'.repeat(30000) in 'HEAD' + 'base'.repeat(30000));
// These test cases check if it does not crash and throws appropriate error. // These test cases check if it does not crash and throws appropriate error.
assertThrowsInstanceOf(() => { 1 in 'hello' }, TypeError); assert.throws(TypeError, () => { 1 in 'hello' });
assertThrowsInstanceOf(() => { 'hello' in 1 }, TypeError); assert.throws(TypeError, () => { 'hello' in 1 });
assertThrowsInstanceOf(() => { 'hello' in null }, TypeError); assert.throws(TypeError, () => { 'hello' in null });
assertThrowsInstanceOf(() => { null in 'hello' }, TypeError); assert.throws(TypeError, () => { null in 'hello' });
assertThrowsInstanceOf(() => { null in null }, TypeError); assert.throws(TypeError, () => { null in null });
assertThrowsInstanceOf(() => { 'hello' in true }, TypeError); assert.throws(TypeError, () => { 'hello' in true });
assertThrowsInstanceOf(() => { false in 1.1 }, TypeError); assert.throws(TypeError, () => { false in 1.1 });
assertThrowsInstanceOf(() => { Symbol.iterator in undefined }, TypeError); assert.throws(TypeError, () => { Symbol.iterator in undefined });
assertThrowsInstanceOf(() => { [] in undefined }, TypeError); assert.throws(TypeError, () => { [] in undefined });
assertThrowsInstanceOf(() => { /a/ in 'hello' }, TypeError); assert.throws(TypeError, () => { /a/ in 'hello' });
var str = 'hello'; var str = 'hello';
assertThrowsInstanceOf(() => { str in 'hello' }, TypeError); assert.throws(TypeError, () => { str in 'hello' });
class A {}; class A {};
assertThrowsInstanceOf(() => { new A() in undefined }, TypeError); assert.throws(TypeError, () => { new A() in undefined });
var a = new A(); var a = new A();
a.b = 1.1; a.b = 1.1;
assertThrowsInstanceOf(() => { a.b in 1.1 }, TypeError); assert.throws(TypeError, () => { a.b in 1.1 });

View File

@ -13,25 +13,25 @@ esid: pending
// TDZ for lexical |let| bindings with optional chaining. // TDZ for lexical |let| bindings with optional chaining.
{ {
assertThrowsInstanceOf(() => { assert.throws(ReferenceError, () => {
const Null = null; const Null = null;
Null?.[b]; Null?.[b];
b = 0; b = 0;
let b; let b;
}, ReferenceError); });
assertThrowsInstanceOf(() => { assert.throws(ReferenceError, () => {
const Null = null; const Null = null;
Null?.[b](); Null?.[b]();
b = 0; b = 0;
let b; let b;
}, ReferenceError); });
assertThrowsInstanceOf(() => { assert.throws(ReferenceError, () => {
const Null = null; const Null = null;
delete Null?.[b]; delete Null?.[b];
b = 0; b = 0;
let b; let b;
}, ReferenceError); });
} }

View File

@ -23,7 +23,7 @@ function notEvaluated() {
assert.sameValue(a, false); assert.sameValue(a, false);
const b = true; const b = true;
assertThrowsInstanceOf(() => { b &&= 1; }, TypeError); assert.throws(TypeError, () => { b &&= 1; });
assert.sameValue(b, true); assert.sameValue(b, true);
} }
@ -37,7 +37,7 @@ function notEvaluated() {
let g = function fn() { let g = function fn() {
"use strict"; "use strict";
assertThrowsInstanceOf(() => { fn &&= 1; }, TypeError); assert.throws(TypeError, () => { fn &&= 1; });
assert.sameValue(fn, g); assert.sameValue(fn, g);
}; };
g(); g();
@ -50,7 +50,7 @@ function notEvaluated() {
assert.sameValue(a, true); assert.sameValue(a, true);
const b = false; const b = false;
assertThrowsInstanceOf(() => { b ||= 0; }, TypeError); assert.throws(TypeError, () => { b ||= 0; });
assert.sameValue(b, false); assert.sameValue(b, false);
} }
@ -77,7 +77,7 @@ function notEvaluated() {
assert.sameValue(a, true); assert.sameValue(a, true);
const b = null; const b = null;
assertThrowsInstanceOf(() => { b ??= 0; }, TypeError); assert.throws(TypeError, () => { b ??= 0; });
assert.sameValue(b, null); assert.sameValue(b, null);
} }

View File

@ -13,53 +13,53 @@ esid: pending
// TDZ for lexical |let| bindings. // TDZ for lexical |let| bindings.
{ {
assertThrowsInstanceOf(() => { let a = (a &&= 0); }, ReferenceError); assert.throws(ReferenceError, () => { let a = (a &&= 0); });
assertThrowsInstanceOf(() => { let a = (a ||= 0); }, ReferenceError); assert.throws(ReferenceError, () => { let a = (a ||= 0); });
assertThrowsInstanceOf(() => { let a = (a ??= 0); }, ReferenceError); assert.throws(ReferenceError, () => { let a = (a ??= 0); });
} }
// TDZ for lexical |const| bindings. // TDZ for lexical |const| bindings.
{ {
assertThrowsInstanceOf(() => { const a = (a &&= 0); }, ReferenceError); assert.throws(ReferenceError, () => { const a = (a &&= 0); });
assertThrowsInstanceOf(() => { const a = (a ||= 0); }, ReferenceError); assert.throws(ReferenceError, () => { const a = (a ||= 0); });
assertThrowsInstanceOf(() => { const a = (a ??= 0); }, ReferenceError); assert.throws(ReferenceError, () => { const a = (a ??= 0); });
} }
// TDZ for parameter expressions. // TDZ for parameter expressions.
{ {
assertThrowsInstanceOf((a = (b &&= 0), b) => {}, ReferenceError); assert.throws(ReferenceError, (a = (b &&= 0), b) => {});
assertThrowsInstanceOf((a = (b ||= 0), b) => {}, ReferenceError); assert.throws(ReferenceError, (a = (b ||= 0), b) => {});
assertThrowsInstanceOf((a = (b ??= 0), b) => {}, ReferenceError); assert.throws(ReferenceError, (a = (b ??= 0), b) => {});
} }
// TDZ for |class| bindings. // TDZ for |class| bindings.
{ {
assertThrowsInstanceOf(() => { class a extends (a &&= 0) {} }, ReferenceError); assert.throws(ReferenceError, () => { class a extends (a &&= 0) {} });
assertThrowsInstanceOf(() => { class a extends (a ||= 0) {} }, ReferenceError); assert.throws(ReferenceError, () => { class a extends (a ||= 0) {} });
assertThrowsInstanceOf(() => { class a extends (a ??= 0) {} }, ReferenceError); assert.throws(ReferenceError, () => { class a extends (a ??= 0) {} });
} }
// TDZ for lexical |let| bindings with conditional assignment. // TDZ for lexical |let| bindings with conditional assignment.
{ {
assertThrowsInstanceOf(() => { assert.throws(ReferenceError, () => {
const False = false; const False = false;
False &&= b; False &&= b;
b = 2; b = 2;
let b; let b;
}, ReferenceError); });
assertThrowsInstanceOf(() => { assert.throws(ReferenceError, () => {
const True = true; const True = true;
True ||= b; True ||= b;
b = 2; b = 2;
let b; let b;
}, ReferenceError); });
assertThrowsInstanceOf(() => { assert.throws(ReferenceError, () => {
const NonNull = {}; const NonNull = {};
NonNull ??= b; NonNull ??= b;
b = 2; b = 2;
let b; let b;
}, ReferenceError); });
} }