|
|
@@ -17,6 +17,64 @@ var tests = [
|
|
|
assert.isFalse(Reflect.set({ p: 43 }, 'p', 42, receiver), "For existing accessor property on receiver [[Set]] returns false even when an own descriptor exists on the target");
|
|
|
}
|
|
|
},
|
|
|
+ {
|
|
|
+ name: "Reflect.apply API",
|
|
|
+ body: function () {
|
|
|
+ function foo() {}
|
|
|
+
|
|
|
+ assert.throws(function() { Reflect.apply() }, TypeError, "", "Reflect.apply: argument is not a Function object");
|
|
|
+
|
|
|
+ assert.throws(function() { Reflect.apply(foo) }, TypeError, "argumentsList default == undefined", "Reflect.apply: argument is not an array or array-like object");
|
|
|
+ assert.throws(function() { Reflect.apply(foo, undefined) }, TypeError, "argumentsList default == undefined", "Reflect.apply: argument is not an array or array-like object");
|
|
|
+ assert.throws(function() { Reflect.apply(foo, undefined, undefined) }, TypeError, "argumentsList == undefined", "Reflect.apply: argument is not an array or array-like object");
|
|
|
+ assert.throws(function() { Reflect.apply(foo, undefined, null) }, TypeError, "argumentsList == null", "Reflect.apply: argument is not an array or array-like object");
|
|
|
+ assert.throws(function() { Reflect.apply(foo, undefined, false) }, TypeError, "argumentsList == false", "Reflect.apply: argument is not an array or array-like object");
|
|
|
+ assert.throws(function() { Reflect.apply(foo, undefined, 1) }, TypeError, "argumentsList == 1", "Reflect.apply: argument is not an array or array-like object");
|
|
|
+ assert.throws(function() { Reflect.apply(foo, undefined, Number(42)) }, TypeError, "argumentsList == Number(42)", "Reflect.apply: argument is not an array or array-like object");
|
|
|
+
|
|
|
+ assert.doesNotThrow(function() { Reflect.apply(foo, undefined, {}) });
|
|
|
+ assert.doesNotThrow(function() { Reflect.apply(foo, undefined, []) });
|
|
|
+
|
|
|
+ assert.doesNotThrow(function() { Reflect.apply(foo, undefined, new Int32Array()) }, "TypedArray should be a valid value for arguments");
|
|
|
+ assert.doesNotThrow(function() { Reflect.apply(foo, undefined, new Error()) }, "Error should be a valid value for arguments");
|
|
|
+ assert.doesNotThrow(function() { Reflect.apply(foo, undefined, new Proxy({}, {})) }, "Proxy should be a valid value for arguments");
|
|
|
+ assert.doesNotThrow(function() { Reflect.apply(foo, undefined, new Promise(r => r())) }, "Promise should be a valid value for arguments");
|
|
|
+ assert.doesNotThrow(function() { Reflect.apply(foo, undefined, new Number(42)) }, "a Number object should be a valid value for arguments");
|
|
|
+
|
|
|
+ assert.doesNotThrow(function() { Reflect.apply(foo, undefined, Function("return 123")) }, "a Function object should be a valid value for arguments");
|
|
|
+ assert.doesNotThrow(function() { Reflect.apply(foo, undefined, new Function("return 123")) }, "a Function object should be a valid value for arguments");
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: "Reflect.construct API",
|
|
|
+ body: function () {
|
|
|
+ function foo() {}
|
|
|
+
|
|
|
+ assert.throws(function() { Reflect.construct() }, TypeError, "" ,"'target' is not a constructor");
|
|
|
+
|
|
|
+ assert.throws(function() { Reflect.construct(foo) }, TypeError, "argumentsList default == undefined" ,"Reflect.construct: argument is not an array or array-like object");
|
|
|
+ assert.throws(function() { Reflect.construct(foo, undefined) }, TypeError, "argumentsList == undefined" ,"Reflect.construct: argument is not an array or array-like object");
|
|
|
+ assert.throws(function() { Reflect.construct(foo, null) }, TypeError, "argumentsList == null" ,"Reflect.construct: argument is not an array or array-like object");
|
|
|
+ assert.throws(function() { Reflect.construct(foo, false) }, TypeError, "argumentsList == false" ,"Reflect.construct: argument is not an array or array-like object");
|
|
|
+ assert.throws(function() { Reflect.construct(foo, 1) }, TypeError, "argumentsList == 1" ,"Reflect.construct: argument is not an array or array-like object");
|
|
|
+ assert.throws(function() { Reflect.construct(foo, Number(42)) }, TypeError, "argumentsList == Number(42)" ,"Reflect.construct: argument is not an array or array-like object");
|
|
|
+
|
|
|
+ assert.doesNotThrow(function() { Reflect.construct(foo, {}) });
|
|
|
+ assert.doesNotThrow(function() { Reflect.construct(foo, []) });
|
|
|
+ assert.doesNotThrow(function() { Reflect.construct(foo, [], Array) });
|
|
|
+
|
|
|
+ assert.doesNotThrow(function() { Reflect.construct(foo, new Int32Array()) }, "TypedArray should be a valid value for arguments");
|
|
|
+ assert.doesNotThrow(function() { Reflect.construct(foo, new Error()) }, "Error should be a valid value for arguments");
|
|
|
+ assert.doesNotThrow(function() { Reflect.construct(foo, new Proxy({}, {})) }, "Proxy should be a valid value for arguments");
|
|
|
+ assert.doesNotThrow(function() { Reflect.construct(foo, new Promise(r => r())) }, "Promise should be a valid value for arguments");
|
|
|
+ assert.doesNotThrow(function() { Reflect.construct(foo, new Number(42)) }, "a Number object should be a valid value for arguments");
|
|
|
+
|
|
|
+ assert.doesNotThrow(function() { Reflect.construct(foo, Function("return 123")) }, "a Function object should be a valid value for arguments");
|
|
|
+ assert.doesNotThrow(function() { Reflect.construct(foo, new Function("return 123")) }, "a Function object should be a valid value for arguments");
|
|
|
+
|
|
|
+ assert.throws(function() { Reflect.construct(Reflect.apply, undefined) }, TypeError, "" ,"'target' is not a constructor");
|
|
|
+ }
|
|
|
+ },
|
|
|
{
|
|
|
name: "Reflect.construct",
|
|
|
body: function () {
|