mirror of
https://github.com/tc39/test262.git
synced 2025-09-24 02:28:05 +02:00
Replace assertThrowsInstanceOf with assert.throws in sm/Proxy
This commit is contained in:
parent
ad6b866f42
commit
f30120ab96
@ -21,9 +21,7 @@ var proxy = new Proxy(target, {
|
||||
}
|
||||
});
|
||||
|
||||
assertThrowsInstanceOf(
|
||||
() => Object.defineProperty(proxy, "test", {writable: false}), TypeError);
|
||||
assert.throws(TypeError, () => Object.defineProperty(proxy, "test", {writable: false}));
|
||||
|
||||
assertThrowsInstanceOf(
|
||||
() => Reflect.defineProperty(proxy, "test", {writable: false}), TypeError);
|
||||
assert.throws(TypeError, () => Reflect.defineProperty(proxy, "test", {writable: false}));
|
||||
|
||||
|
@ -23,6 +23,6 @@ var proxy = new Proxy(target, {
|
||||
assert.sameValue(delete proxy.missing, true);
|
||||
assert.sameValue(Reflect.deleteProperty(proxy, "missing"), true);
|
||||
|
||||
assertThrowsInstanceOf(() => { delete proxy.test; }, TypeError);
|
||||
assertThrowsInstanceOf(() => Reflect.deleteProperty(proxy, "test"), TypeError);
|
||||
assert.throws(TypeError, () => { delete proxy.test; });
|
||||
assert.throws(TypeError, () => Reflect.deleteProperty(proxy, "test"));
|
||||
|
||||
|
@ -47,7 +47,7 @@ p = rev.proxy;
|
||||
|
||||
assert.sameValue(Object.getPrototypeOf(p), Object.prototype);
|
||||
rev.revoke();
|
||||
assertThrowsInstanceOf(() => Object.getPrototypeOf(p), TypeError);
|
||||
assert.throws(TypeError, () => Object.getPrototypeOf(p));
|
||||
|
||||
// 4. Let target be the value of the [[ProxyTarget]] internal slot of O.
|
||||
// 5. Let trap be ? GetMethod(handler, "getPrototypeOf").
|
||||
@ -67,8 +67,7 @@ assertThrowsValue(() => Object.getPrototypeOf(p), 42);
|
||||
// The trap might not be callable.
|
||||
p = new Proxy({}, { getPrototypeOf: 17 });
|
||||
|
||||
assertThrowsInstanceOf(() => Object.getPrototypeOf(p),
|
||||
TypeError);
|
||||
assert.throws(TypeError, () => Object.getPrototypeOf(p));
|
||||
|
||||
// 6. If trap is undefined, then
|
||||
// a. Return ? target.[[GetPrototypeOf]]().
|
||||
@ -154,44 +153,34 @@ p = new Proxy(typeTestingTarget, { getPrototypeOf() { return rval; } });
|
||||
function returnsPrimitives()
|
||||
{
|
||||
rval = undefined;
|
||||
assertThrowsInstanceOf(() => Object.getPrototypeOf(p),
|
||||
TypeError);
|
||||
assert.throws(TypeError, () => Object.getPrototypeOf(p));
|
||||
|
||||
rval = true;
|
||||
assertThrowsInstanceOf(() => Object.getPrototypeOf(p),
|
||||
TypeError);
|
||||
assert.throws(TypeError, () => Object.getPrototypeOf(p));
|
||||
|
||||
rval = false;
|
||||
assertThrowsInstanceOf(() => Object.getPrototypeOf(p),
|
||||
TypeError);
|
||||
assert.throws(TypeError, () => Object.getPrototypeOf(p));
|
||||
|
||||
rval = 0.0;
|
||||
assertThrowsInstanceOf(() => Object.getPrototypeOf(p),
|
||||
TypeError);
|
||||
assert.throws(TypeError, () => Object.getPrototypeOf(p));
|
||||
|
||||
rval = -0.0;
|
||||
assertThrowsInstanceOf(() => Object.getPrototypeOf(p),
|
||||
TypeError);
|
||||
assert.throws(TypeError, () => Object.getPrototypeOf(p));
|
||||
|
||||
rval = 3.141592654;
|
||||
assertThrowsInstanceOf(() => Object.getPrototypeOf(p),
|
||||
TypeError);
|
||||
assert.throws(TypeError, () => Object.getPrototypeOf(p));
|
||||
|
||||
rval = NaN;
|
||||
assertThrowsInstanceOf(() => Object.getPrototypeOf(p),
|
||||
TypeError);
|
||||
assert.throws(TypeError, () => Object.getPrototypeOf(p));
|
||||
|
||||
rval = -Infinity;
|
||||
assertThrowsInstanceOf(() => Object.getPrototypeOf(p),
|
||||
TypeError);
|
||||
assert.throws(TypeError, () => Object.getPrototypeOf(p));
|
||||
|
||||
rval = "[[Prototype]] FOR REALZ";
|
||||
assertThrowsInstanceOf(() => Object.getPrototypeOf(p),
|
||||
TypeError);
|
||||
assert.throws(TypeError, () => Object.getPrototypeOf(p));
|
||||
|
||||
rval = Symbol("[[Prototype]] FOR REALZ");
|
||||
assertThrowsInstanceOf(() => Object.getPrototypeOf(p),
|
||||
TypeError);
|
||||
assert.throws(TypeError, () => Object.getPrototypeOf(p));
|
||||
}
|
||||
|
||||
returnsPrimitives();
|
||||
@ -270,8 +259,7 @@ assert.sameValue(log[0], "act1 again");
|
||||
|
||||
act1 = act2 = nop;
|
||||
rval = /a/;
|
||||
assertThrowsInstanceOf(() => Object.getPrototypeOf(p),
|
||||
TypeError);
|
||||
assert.throws(TypeError, () => Object.getPrototypeOf(p));
|
||||
|
||||
// 13. Return handlerProto.
|
||||
|
||||
|
@ -15,8 +15,8 @@ function makeProxy(type) {
|
||||
|
||||
for (var type of [123, 12.5, true, false, undefined, null, {}, []]) {
|
||||
var proxy = makeProxy(type);
|
||||
assertThrowsInstanceOf(() => Object.ownKeys(proxy), TypeError);
|
||||
assertThrowsInstanceOf(() => Object.getOwnPropertyNames(proxy), TypeError);
|
||||
assert.throws(TypeError, () => Object.ownKeys(proxy));
|
||||
assert.throws(TypeError, () => Object.getOwnPropertyNames(proxy));
|
||||
}
|
||||
|
||||
type = Symbol();
|
||||
|
@ -27,11 +27,11 @@ print(BUGNUMBER + ": " + summary);
|
||||
|
||||
var target = Object.preventExtensions({ a: 1 });
|
||||
var proxy = new Proxy(target, { ownKeys(t) { return ["a", "a"]; } });
|
||||
assertThrowsInstanceOf(() => Object.getOwnPropertyNames(proxy), TypeError);
|
||||
assert.throws(TypeError, () => Object.getOwnPropertyNames(proxy));
|
||||
|
||||
target = Object.freeze({ a: 1 });
|
||||
proxy = new Proxy(target, { ownKeys(t) { return ["a", "a"]; } });
|
||||
assertThrowsInstanceOf(() => Object.getOwnPropertyNames(proxy), TypeError);
|
||||
assert.throws(TypeError, () => Object.getOwnPropertyNames(proxy));
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
@ -18,10 +18,10 @@ function callable() {}
|
||||
|
||||
var p = new Proxy(callable, handler);
|
||||
|
||||
assertThrowsInstanceOf(function () { new p(); }, TypeError,
|
||||
assert.throws(TypeError, function () { new p(); },
|
||||
"[[Construct must throw if an object is not returned.");
|
||||
|
||||
handler.construct = bogusConstructUndefined;
|
||||
assertThrowsInstanceOf(function () { new p(); }, TypeError,
|
||||
assert.throws(TypeError, function () { new p(); },
|
||||
"[[Construct must throw if an object is not returned.");
|
||||
|
||||
|
@ -27,6 +27,6 @@ var y = new Proxy({}, {
|
||||
})
|
||||
|
||||
// This will invoke [[Set]] on the target, with the proxy as receiver.
|
||||
assertThrowsInstanceOf(() => y.a = 1, TypeError);
|
||||
assertThrowsInstanceOf(() => y.b = 2, TypeError);
|
||||
assert.throws(TypeError, () => y.a = 1);
|
||||
assert.throws(TypeError, () => y.b = 2);
|
||||
|
||||
|
@ -22,9 +22,7 @@ var proxy = new Proxy(target, {
|
||||
}
|
||||
});
|
||||
|
||||
assertThrowsInstanceOf(() => Object.getOwnPropertyDescriptor(proxy, "test"),
|
||||
TypeError);
|
||||
assert.throws(TypeError, () => Object.getOwnPropertyDescriptor(proxy, "test"));
|
||||
|
||||
assertThrowsInstanceOf(() => Reflect.getOwnPropertyDescriptor(proxy, "test"),
|
||||
TypeError);
|
||||
assert.throws(TypeError, () => Reflect.getOwnPropertyDescriptor(proxy, "test"));
|
||||
|
||||
|
@ -57,8 +57,8 @@ assert.sameValue(createProxy({}).a, undefined);
|
||||
assert.sameValue(createProxy({a: 5}).a, 5);
|
||||
|
||||
// [[Set]]
|
||||
assertThrowsInstanceOf(() => createProxy({}).a = 0, TypeError);
|
||||
assertThrowsInstanceOf(() => createProxy({a: 5}).a = 0, TypeError);
|
||||
assert.throws(TypeError, () => createProxy({}).a = 0);
|
||||
assert.throws(TypeError, () => createProxy({a: 5}).a = 0);
|
||||
|
||||
// [[Delete]]
|
||||
assert.sameValue(delete createProxy({}).a, true);
|
||||
@ -77,6 +77,5 @@ assert.sameValue(createProxy(function() { return "ok" })(), "ok");
|
||||
// [[ConstructorKind]] is "base" per FunctionAllocate) accesses
|
||||
// |new.target.prototype| to create the |this| for the construct operation, that
|
||||
// would be returned if |return obj;| didn't override it.
|
||||
assertThrowsInstanceOf(() => new (createProxy(function q(){ return obj; })),
|
||||
TypeError);
|
||||
assert.throws(TypeError, () => new (createProxy(function q(){ return obj; })));
|
||||
|
||||
|
@ -119,9 +119,9 @@ for (let {constructor, args = []} of constructors) {
|
||||
}
|
||||
});
|
||||
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
Reflect.construct(constructor, args, proxy);
|
||||
}, TypeError);
|
||||
});
|
||||
|
||||
assert.sameValue(revoked, 1);
|
||||
}
|
||||
|
@ -50,45 +50,35 @@ var originalProto = Reflect.getPrototypeOf(p);
|
||||
assert.sameValue(originalProto, Object.prototype);
|
||||
|
||||
rev.revoke();
|
||||
assertThrowsInstanceOf(() => Reflect.setPrototypeOf(p, originalProto),
|
||||
TypeError);
|
||||
assertThrowsInstanceOf(() => Reflect.setPrototypeOf(p, null),
|
||||
TypeError);
|
||||
assert.throws(TypeError, () => Reflect.setPrototypeOf(p, originalProto));
|
||||
assert.throws(TypeError, () => Reflect.setPrototypeOf(p, null));
|
||||
|
||||
// 6. Let trap be ? GetMethod(handler, "setPrototypeOf").
|
||||
|
||||
// handler has uncallable (and not null/undefined) property
|
||||
p = new Proxy({}, { setPrototypeOf: 9 });
|
||||
assertThrowsInstanceOf(() => Reflect.setPrototypeOf(p, null),
|
||||
TypeError);
|
||||
assert.throws(TypeError, () => Reflect.setPrototypeOf(p, null));
|
||||
|
||||
p = new Proxy({}, { setPrototypeOf: -3.7 });
|
||||
assertThrowsInstanceOf(() => Reflect.setPrototypeOf(p, null),
|
||||
TypeError);
|
||||
assert.throws(TypeError, () => Reflect.setPrototypeOf(p, null));
|
||||
|
||||
p = new Proxy({}, { setPrototypeOf: NaN });
|
||||
assertThrowsInstanceOf(() => Reflect.setPrototypeOf(p, null),
|
||||
TypeError);
|
||||
assert.throws(TypeError, () => Reflect.setPrototypeOf(p, null));
|
||||
|
||||
p = new Proxy({}, { setPrototypeOf: Infinity });
|
||||
assertThrowsInstanceOf(() => Reflect.setPrototypeOf(p, null),
|
||||
TypeError);
|
||||
assert.throws(TypeError, () => Reflect.setPrototypeOf(p, null));
|
||||
|
||||
p = new Proxy({}, { setPrototypeOf: true });
|
||||
assertThrowsInstanceOf(() => Reflect.setPrototypeOf(p, null),
|
||||
TypeError);
|
||||
assert.throws(TypeError, () => Reflect.setPrototypeOf(p, null));
|
||||
|
||||
p = new Proxy({}, { setPrototypeOf: /x/ });
|
||||
assertThrowsInstanceOf(() => Reflect.setPrototypeOf(p, null),
|
||||
TypeError);
|
||||
assert.throws(TypeError, () => Reflect.setPrototypeOf(p, null));
|
||||
|
||||
p = new Proxy({}, { setPrototypeOf: Symbol(42) });
|
||||
assertThrowsInstanceOf(() => Reflect.setPrototypeOf(p, null),
|
||||
TypeError);
|
||||
assert.throws(TypeError, () => Reflect.setPrototypeOf(p, null));
|
||||
|
||||
p = new Proxy({}, { setPrototypeOf: class X {} });
|
||||
assertThrowsInstanceOf(() => Reflect.setPrototypeOf(p, null),
|
||||
TypeError);
|
||||
assert.throws(TypeError, () => Reflect.setPrototypeOf(p, null));
|
||||
|
||||
p = new Proxy({}, observe({}));
|
||||
|
||||
@ -251,8 +241,7 @@ var newProto;
|
||||
p = new Proxy(Object.preventExtensions(Object.create(Math)),
|
||||
{ setPrototypeOf(t, p) { return true; } });
|
||||
|
||||
assertThrowsInstanceOf(() => Reflect.setPrototypeOf(p, null),
|
||||
TypeError);
|
||||
assert.throws(TypeError, () => Reflect.setPrototypeOf(p, null));
|
||||
|
||||
// 14. Return true.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user