use `isConstructor` assertion in "non-constructor" tests

This commit is contained in:
Jordan Harband 2022-04-26 12:05:01 -07:00 committed by Rick Waldron
parent 7f2668f807
commit 28b31c0bf1
7 changed files with 60 additions and 9 deletions

View File

@ -18,9 +18,16 @@ info: |
b. If C is null, let C be undefined.
[...]
9. If IsConstructor(C) is false, throw a TypeError exception.
features: [Symbol.species]
includes: [isConstructor.js]
features: [Symbol.species, Reflect.construct]
---*/
assert.sameValue(
isConstructor(parseInt),
false,
'precondition: isConstructor(parseInt) must return false'
);
var a = [];
a.constructor = {};

View File

@ -19,9 +19,16 @@ info: |
b. If C is null, let C be undefined.
[...]
9. If IsConstructor(C) is false, throw a TypeError exception.
features: [Symbol.species]
includes: [isConstructor.js]
features: [Symbol.species, Reflect.construct]
---*/
assert.sameValue(
isConstructor(parseInt),
false,
'precondition: isConstructor(parseInt) must return false'
);
var a = [];
var callCount = 0;
var cb = function() {
@ -33,5 +40,5 @@ a.constructor[Symbol.species] = parseInt;
assert.throws(TypeError, function() {
a.filter(cb);
});
}, 'a.filter(cb) throws a TypeError exception');
assert.sameValue(callCount, 0);

View File

@ -19,9 +19,16 @@ info: |
b. If C is null, let C be undefined.
[...]
9. If IsConstructor(C) is false, throw a TypeError exception.
features: [Symbol.species]
includes: [isConstructor.js]
features: [Symbol.species, Reflect.construct]
---*/
assert.sameValue(
isConstructor(parseInt),
false,
'precondition: isConstructor(parseInt) must return false'
);
var a = [];
var callCount = 0;
var cb = function() {
@ -33,5 +40,5 @@ a.constructor[Symbol.species] = parseInt;
assert.throws(TypeError, function() {
a.map(cb);
});
}, 'a.map(cb) throws a TypeError exception');
assert.sameValue(callCount, 0);

View File

@ -19,9 +19,16 @@ info: |
b. If C is null, let C be undefined.
[...]
9. If IsConstructor(C) is false, throw a TypeError exception.
features: [Symbol.species]
includes: [isConstructor.js]
features: [Symbol.species, Reflect.construct]
---*/
assert.sameValue(
isConstructor(parseInt),
false,
'precondition: isConstructor(parseInt) must return false'
);
var a = [];
a.constructor = {};
@ -29,4 +36,4 @@ a.constructor[Symbol.species] = parseInt;
assert.throws(TypeError, function() {
a.slice();
});
}, 'a.slice() throws a TypeError exception');

View File

@ -19,9 +19,16 @@ info: |
b. If C is null, let C be undefined.
[...]
9. If IsConstructor(C) is false, throw a TypeError exception.
features: [Symbol.species]
includes: [isConstructor.js]
features: [Symbol.species, Reflect.construct]
---*/
assert.sameValue(
isConstructor(parseInt),
false,
'precondition: isConstructor(parseInt) must return false'
);
var a = [];
a.constructor = {};
@ -29,4 +36,4 @@ a.constructor[Symbol.species] = parseInt;
assert.throws(TypeError, function() {
a.splice();
});
}, 'a.splice() throws a TypeError exception');

View File

@ -5,9 +5,17 @@
info: RegExp.prototype.toString has not prototype property
es5id: 15.10.6.4_A6
description: Checking RegExp.prototype.toString.prototype
includes: [isConstructor.js]
features: [Reflect.construct]
---*/
assert.sameValue(
RegExp.prototype.toString.prototype,
undefined,
'The value of RegExp.prototype.toString.prototype is expected to equal undefined'
);
assert.sameValue(
isConstructor(RegExp.prototype.toString),
false,
'isConstructor(RegExp.prototype.toString) must return false'
);

View File

@ -5,6 +5,8 @@
info: RegExp.prototype.toString can't be used as constructor
es5id: 15.10.6.4_A7
description: Checking if creating the RegExp.prototype.toString object fails
includes: [isConstructor.js]
features: [Reflect.construct]
---*/
var __FACTORY = RegExp.prototype.toString;
@ -20,4 +22,10 @@ try {
);
}
assert.sameValue(
isConstructor(RegExp.prototype.toString),
false,
'isConstructor(RegExp.prototype.toString) must return false'
);
// TODO: Convert to assert.throws() format.