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