From 88ff239de107451f23ab795f77d4c3ac0a6ad850 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bargull?= Date: Wed, 30 Apr 2025 14:15:50 +0200 Subject: [PATCH] Replace assertThrowsInstanceOf with assert.throws in sm/object --- .../sm/object/accessor-arguments-rest.js | 18 +++++++++--------- .../sm/object/accessor-non-constructor.js | 16 ++++++++-------- test/staging/sm/object/bug-1150906.js | 2 +- .../sm/object/defineGetter-defineSetter.js | 6 +++--- .../defineProperties-callable-accessor.js | 4 ++-- test/staging/sm/object/entries.js | 6 +++--- .../sm/object/getOwnPropertyDescriptor.js | 6 +++--- .../staging/sm/object/getOwnPropertySymbols.js | 6 +++--- test/staging/sm/object/getPrototypeOf.js | 6 +++--- test/staging/sm/object/hasOwn.js | 2 +- test/staging/sm/object/keys.js | 6 +++--- .../sm/object/method-non-constructor.js | 8 ++++---- .../object-create-with-primitive-second-arg.js | 2 +- .../object/setPrototypeOf-cross-realm-cycle.js | 4 ++-- test/staging/sm/object/toPrimitive.js | 10 +++++----- .../sm/object/values-entries-typedarray.js | 2 +- test/staging/sm/object/values.js | 6 +++--- 17 files changed, 55 insertions(+), 55 deletions(-) diff --git a/test/staging/sm/object/accessor-arguments-rest.js b/test/staging/sm/object/accessor-arguments-rest.js index 60090d2afc..878fc73340 100644 --- a/test/staging/sm/object/accessor-arguments-rest.js +++ b/test/staging/sm/object/accessor-arguments-rest.js @@ -9,16 +9,16 @@ description: | pending esid: pending ---*/ -assertThrowsInstanceOf(() => eval("({ get x(...a) { } })"), SyntaxError); -assertThrowsInstanceOf(() => eval("({ get x(a, ...b) { } })"), SyntaxError); -assertThrowsInstanceOf(() => eval("({ get x([a], ...b) { } })"), SyntaxError); -assertThrowsInstanceOf(() => eval("({ get x({a}, ...b) { } })"), SyntaxError); -assertThrowsInstanceOf(() => eval("({ get x({a: A}, ...b) { } })"), SyntaxError); +assert.throws(SyntaxError, () => eval("({ get x(...a) { } })")); +assert.throws(SyntaxError, () => eval("({ get x(a, ...b) { } })")); +assert.throws(SyntaxError, () => eval("({ get x([a], ...b) { } })")); +assert.throws(SyntaxError, () => eval("({ get x({a}, ...b) { } })")); +assert.throws(SyntaxError, () => eval("({ get x({a: A}, ...b) { } })")); -assertThrowsInstanceOf(() => eval("({ set x(...a) { } })"), SyntaxError); -assertThrowsInstanceOf(() => eval("({ set x(a, ...b) { } })"), SyntaxError); -assertThrowsInstanceOf(() => eval("({ set x([a], ...b) { } })"), SyntaxError); -assertThrowsInstanceOf(() => eval("({ set x({a: A}, ...b) { } })"), SyntaxError); +assert.throws(SyntaxError, () => eval("({ set x(...a) { } })")); +assert.throws(SyntaxError, () => eval("({ set x(a, ...b) { } })")); +assert.throws(SyntaxError, () => eval("({ set x([a], ...b) { } })")); +assert.throws(SyntaxError, () => eval("({ set x({a: A}, ...b) { } })")); ({ get(...a) { } }); ({ get(a, ...b) { } }); diff --git a/test/staging/sm/object/accessor-non-constructor.js b/test/staging/sm/object/accessor-non-constructor.js index a00cfd1c59..e3e39a36db 100644 --- a/test/staging/sm/object/accessor-non-constructor.js +++ b/test/staging/sm/object/accessor-non-constructor.js @@ -10,20 +10,20 @@ description: | esid: pending ---*/ var obj = { get a() { return 1; } }; -assertThrowsInstanceOf(() => { +assert.throws(TypeError, () => { new Object.getOwnPropertyDescriptor(obj, "a").get -}, TypeError); +}); obj = { set a(b) { } }; -assertThrowsInstanceOf(() => { +assert.throws(TypeError, () => { new Object.getOwnPropertyDescriptor(obj, "a").set -}, TypeError); +}); obj = { get a() { return 1; }, set a(b) { } }; -assertThrowsInstanceOf(() => { +assert.throws(TypeError, () => { new Object.getOwnPropertyDescriptor(obj, "a").get -}, TypeError); -assertThrowsInstanceOf(() => { +}); +assert.throws(TypeError, () => { new Object.getOwnPropertyDescriptor(obj, "a").set -}, TypeError); +}); diff --git a/test/staging/sm/object/bug-1150906.js b/test/staging/sm/object/bug-1150906.js index fa6c636631..ee11a978df 100644 --- a/test/staging/sm/object/bug-1150906.js +++ b/test/staging/sm/object/bug-1150906.js @@ -19,5 +19,5 @@ function f(x) { var obj = f(1); assert.sameValue(obj[0], undefined); assert.sameValue(Object.getOwnPropertyDescriptor(obj, 0).set, undefined); -assertThrowsInstanceOf(() => { "use strict"; obj[0] = 1; }, TypeError); +assert.throws(TypeError, () => { "use strict"; obj[0] = 1; }); diff --git a/test/staging/sm/object/defineGetter-defineSetter.js b/test/staging/sm/object/defineGetter-defineSetter.js index b6fd90b068..2df3b1af14 100644 --- a/test/staging/sm/object/defineGetter-defineSetter.js +++ b/test/staging/sm/object/defineGetter-defineSetter.js @@ -34,12 +34,12 @@ let verifyProxy = new Proxy({}, { for (let define of [Object.prototype.__defineGetter__, Object.prototype.__defineSetter__]) { // null/undefined |this| value for (let thisv of [undefined, null]) - assertThrowsInstanceOf(() => define.call(thisv, "x", define), TypeError); + assert.throws(TypeError, () => define.call(thisv, "x", define)); // non-callable getter/setter let nonCallable = [{}, [], new Proxy({}, {})]; for (let value of nonCallable) - assertThrowsInstanceOf(() => define.call(verifyProxy, "x", value), TypeError); + assert.throws(TypeError, () => define.call(verifyProxy, "x", value)); // ToPropertyKey let key = { @@ -51,7 +51,7 @@ for (let define of [Object.prototype.__defineGetter__, Object.prototype.__define valueOf() { throw "wrongly invoked"; }, toString() { throw "wrongly invoked"; } }; - assertThrowsInstanceOf(() => define.call(verifyProxy, key, define), TypeError); + assert.throws(TypeError, () => define.call(verifyProxy, key, define)); key = { [Symbol.toPrimitive](hint) { diff --git a/test/staging/sm/object/defineProperties-callable-accessor.js b/test/staging/sm/object/defineProperties-callable-accessor.js index 664435c829..b9ad606316 100644 --- a/test/staging/sm/object/defineProperties-callable-accessor.js +++ b/test/staging/sm/object/defineProperties-callable-accessor.js @@ -23,7 +23,7 @@ const descriptors = [ ]; for (const descriptor of descriptors) { - assertThrowsInstanceOf(() => Object.create(null, {x: descriptor}), TypeError); - assertThrowsInstanceOf(() => Object.defineProperties({}, {x: descriptor}), TypeError); + assert.throws(TypeError, () => Object.create(null, {x: descriptor})); + assert.throws(TypeError, () => Object.defineProperties({}, {x: descriptor})); } diff --git a/test/staging/sm/object/entries.js b/test/staging/sm/object/entries.js index 6ffcb8d46a..bd3678cfb8 100644 --- a/test/staging/sm/object/entries.js +++ b/test/staging/sm/object/entries.js @@ -59,9 +59,9 @@ if ("entries" in Object) { entries = Object.entries(o); assert.deepEqual(entries, [["a", 1], ["c", 3]]); - assertThrowsInstanceOf(() => Object.entries(), TypeError); - assertThrowsInstanceOf(() => Object.entries(undefined), TypeError); - assertThrowsInstanceOf(() => Object.entries(null), TypeError); + assert.throws(TypeError, () => Object.entries()); + assert.throws(TypeError, () => Object.entries(undefined)); + assert.throws(TypeError, () => Object.entries(null)); assert.deepEqual(Object.entries(1), []); assert.deepEqual(Object.entries(true), []); diff --git a/test/staging/sm/object/getOwnPropertyDescriptor.js b/test/staging/sm/object/getOwnPropertyDescriptor.js index 64765a18c0..4b30a0533d 100644 --- a/test/staging/sm/object/getOwnPropertyDescriptor.js +++ b/test/staging/sm/object/getOwnPropertyDescriptor.js @@ -15,9 +15,9 @@ var BUGNUMBER = 1079188; var summary = "Coerce the argument passed to Object.getOwnPropertyDescriptor using ToObject"; print(BUGNUMBER + ": " + summary); -assertThrowsInstanceOf(() => Object.getOwnPropertyDescriptor(), TypeError); -assertThrowsInstanceOf(() => Object.getOwnPropertyDescriptor(undefined), TypeError); -assertThrowsInstanceOf(() => Object.getOwnPropertyDescriptor(null), TypeError); +assert.throws(TypeError, () => Object.getOwnPropertyDescriptor()); +assert.throws(TypeError, () => Object.getOwnPropertyDescriptor(undefined)); +assert.throws(TypeError, () => Object.getOwnPropertyDescriptor(null)); Object.getOwnPropertyDescriptor(1); Object.getOwnPropertyDescriptor(true); diff --git a/test/staging/sm/object/getOwnPropertySymbols.js b/test/staging/sm/object/getOwnPropertySymbols.js index 5b433e4488..633ba534f1 100644 --- a/test/staging/sm/object/getOwnPropertySymbols.js +++ b/test/staging/sm/object/getOwnPropertySymbols.js @@ -44,9 +44,9 @@ assert.sameValue(Object.getOwnPropertySymbols(new Proxy(Object.create(obj), {})) // Primitives are coerced to objects; but there are never any symbol-keyed // properties on the resulting wrapper objects. -assertThrowsInstanceOf(() => Object.getOwnPropertySymbols(), TypeError); -assertThrowsInstanceOf(() => Object.getOwnPropertySymbols(undefined), TypeError); -assertThrowsInstanceOf(() => Object.getOwnPropertySymbols(null), TypeError); +assert.throws(TypeError, () => Object.getOwnPropertySymbols()); +assert.throws(TypeError, () => Object.getOwnPropertySymbols(undefined)); +assert.throws(TypeError, () => Object.getOwnPropertySymbols(null)); for (var primitive of [true, 1, 3.14, "hello", Symbol()]) assert.sameValue(Object.getOwnPropertySymbols(primitive).length, 0); diff --git a/test/staging/sm/object/getPrototypeOf.js b/test/staging/sm/object/getPrototypeOf.js index b1ab740b64..152bb70430 100644 --- a/test/staging/sm/object/getPrototypeOf.js +++ b/test/staging/sm/object/getPrototypeOf.js @@ -15,9 +15,9 @@ var BUGNUMBER = 1079090; var summary = "Coerce the argument passed to Object.getPrototypeOf using ToObject"; print(BUGNUMBER + ": " + summary); -assertThrowsInstanceOf(() => Object.getPrototypeOf(), TypeError); -assertThrowsInstanceOf(() => Object.getPrototypeOf(undefined), TypeError); -assertThrowsInstanceOf(() => Object.getPrototypeOf(null), TypeError); +assert.throws(TypeError, () => Object.getPrototypeOf()); +assert.throws(TypeError, () => Object.getPrototypeOf(undefined)); +assert.throws(TypeError, () => Object.getPrototypeOf(null)); assert.sameValue(Object.getPrototypeOf(1), Number.prototype); assert.sameValue(Object.getPrototypeOf(true), Boolean.prototype); diff --git a/test/staging/sm/object/hasOwn.js b/test/staging/sm/object/hasOwn.js index 9febcbdecb..5bdda3142c 100644 --- a/test/staging/sm/object/hasOwn.js +++ b/test/staging/sm/object/hasOwn.js @@ -12,7 +12,7 @@ description: | esid: pending ---*/ assert.sameValue(Object.hasOwn({}, "any"), false); -assertThrowsInstanceOf(() => Object.hasOwn(null, "any"), TypeError); +assert.throws(TypeError, () => Object.hasOwn(null, "any")); var x = { test: 'test value'} var y = {} diff --git a/test/staging/sm/object/keys.js b/test/staging/sm/object/keys.js index 3936ec4c0d..276fdd6e4e 100644 --- a/test/staging/sm/object/keys.js +++ b/test/staging/sm/object/keys.js @@ -15,9 +15,9 @@ var BUGNUMBER = 1038545; var summary = "Coerce the argument passed to Object.keys using ToObject"; print(BUGNUMBER + ": " + summary); -assertThrowsInstanceOf(() => Object.keys(), TypeError); -assertThrowsInstanceOf(() => Object.keys(undefined), TypeError); -assertThrowsInstanceOf(() => Object.keys(null), TypeError); +assert.throws(TypeError, () => Object.keys()); +assert.throws(TypeError, () => Object.keys(undefined)); +assert.throws(TypeError, () => Object.keys(null)); assert.deepEqual(Object.keys(1), []); assert.deepEqual(Object.keys(true), []); diff --git a/test/staging/sm/object/method-non-constructor.js b/test/staging/sm/object/method-non-constructor.js index dbef0d86a1..71b6b43992 100644 --- a/test/staging/sm/object/method-non-constructor.js +++ b/test/staging/sm/object/method-non-constructor.js @@ -10,12 +10,12 @@ description: | esid: pending ---*/ var obj = { method() { } }; -assertThrowsInstanceOf(() => { +assert.throws(TypeError, () => { new obj.method; -}, TypeError); +}); obj = { constructor() { } }; -assertThrowsInstanceOf(() => { +assert.throws(TypeError, () => { new obj.constructor; -}, TypeError); +}); diff --git a/test/staging/sm/object/object-create-with-primitive-second-arg.js b/test/staging/sm/object/object-create-with-primitive-second-arg.js index 0621e9838f..aa426dfe12 100644 --- a/test/staging/sm/object/object-create-with-primitive-second-arg.js +++ b/test/staging/sm/object/object-create-with-primitive-second-arg.js @@ -13,5 +13,5 @@ esid: pending assert.sameValue(Object.getPrototypeOf(Object.create(null, props)), null); }); -assertThrowsInstanceOf(() => Object.create(null, null), TypeError); +assert.throws(TypeError, () => Object.create(null, null)); diff --git a/test/staging/sm/object/setPrototypeOf-cross-realm-cycle.js b/test/staging/sm/object/setPrototypeOf-cross-realm-cycle.js index 6c9d848c37..e0224f283e 100644 --- a/test/staging/sm/object/setPrototypeOf-cross-realm-cycle.js +++ b/test/staging/sm/object/setPrototypeOf-cross-realm-cycle.js @@ -16,6 +16,6 @@ var gw = createNewGlobal(); var obj = {}; var w = gw.Object.create(obj); -assertThrowsInstanceOf(() => Object.setPrototypeOf(obj, w), TypeError); -assertThrowsInstanceOf(() => gw.Object.setPrototypeOf(obj, w), gw.TypeError); +assert.throws(TypeError, () => Object.setPrototypeOf(obj, w)); +assert.throws(gw.TypeError, () => gw.Object.setPrototypeOf(obj, w)); diff --git a/test/staging/sm/object/toPrimitive.js b/test/staging/sm/object/toPrimitive.js index 63e2ae756d..20c9a5407c 100644 --- a/test/staging/sm/object/toPrimitive.js +++ b/test/staging/sm/object/toPrimitive.js @@ -57,7 +57,7 @@ for (var constructor of [Boolean, Number, String, Symbol]) { assert.sameValue(Number(true), 1); assert.sameValue(Number(77.7), 77.7); assert.sameValue(Number("123"), 123); -assertThrowsInstanceOf(() => Number(Symbol.iterator), TypeError); +assert.throws(TypeError, () => Number(Symbol.iterator)); assert.sameValue(String(true), "true"); assert.sameValue(String(77.7), "77.7"); assert.sameValue(String("123"), "123"); @@ -68,9 +68,9 @@ assert.sameValue(ok, true); // delete the @@toPrimitive method from Symbol.prototype. delete Symbol.prototype[Symbol.toPrimitive]; var sym = Symbol("ok"); -assertThrowsInstanceOf(() => `${sym}`, TypeError); -assertThrowsInstanceOf(() => Number(sym), TypeError); -assertThrowsInstanceOf(() => "" + sym, TypeError); +assert.throws(TypeError, () => `${sym}`); +assert.throws(TypeError, () => Number(sym)); +assert.throws(TypeError, () => "" + sym); // However, having deleted that method, converting a Symbol wrapper object does // work: it calls Symbol.prototype.toString(). @@ -106,6 +106,6 @@ var handler = new Proxy({}, { } }); proxy = new Proxy(Object.create(null), handler); -assertThrowsInstanceOf(() => proxy == 0, TypeError); +assert.throws(TypeError, () => proxy == 0); assert.deepEqual(log, [Symbol.toPrimitive, "valueOf", "toString"]); diff --git a/test/staging/sm/object/values-entries-typedarray.js b/test/staging/sm/object/values-entries-typedarray.js index 273b454a59..409ea4833b 100644 --- a/test/staging/sm/object/values-entries-typedarray.js +++ b/test/staging/sm/object/values-entries-typedarray.js @@ -38,7 +38,7 @@ const ACCESS_ON_DETACHED_ARRAY_BUFFER_THROWS = (() => { function maybeThrowOnDetached(fn, returnValue) { if (ACCESS_ON_DETACHED_ARRAY_BUFFER_THROWS) { - assertThrowsInstanceOf(fn, TypeError); + assert.throws(TypeError, fn); return returnValue; } return fn(); diff --git a/test/staging/sm/object/values.js b/test/staging/sm/object/values.js index b35ec38f3b..8f09478fb6 100644 --- a/test/staging/sm/object/values.js +++ b/test/staging/sm/object/values.js @@ -59,9 +59,9 @@ if ("values" in Object) { values = Object.values(o); assert.compareArray(values, [1, 3]); - assertThrowsInstanceOf(() => Object.values(), TypeError); - assertThrowsInstanceOf(() => Object.values(undefined), TypeError); - assertThrowsInstanceOf(() => Object.values(null), TypeError); + assert.throws(TypeError, () => Object.values()); + assert.throws(TypeError, () => Object.values(undefined)); + assert.throws(TypeError, () => Object.values(null)); assert.compareArray(Object.values(1), []); assert.compareArray(Object.values(true), []);