From 28b31c0bf1960878abb36ab8597a0cae224a684d Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 26 Apr 2022 12:05:01 -0700 Subject: [PATCH] use `isConstructor` assertion in "non-constructor" tests --- .../Array/prototype/concat/create-species-non-ctor.js | 9 ++++++++- .../Array/prototype/filter/create-species-non-ctor.js | 11 +++++++++-- .../Array/prototype/map/create-species-non-ctor.js | 11 +++++++++-- .../Array/prototype/slice/create-species-non-ctor.js | 11 +++++++++-- .../Array/prototype/splice/create-species-non-ctor.js | 11 +++++++++-- .../RegExp/prototype/toString/S15.10.6.4_A6.js | 8 ++++++++ .../RegExp/prototype/toString/S15.10.6.4_A7.js | 8 ++++++++ 7 files changed, 60 insertions(+), 9 deletions(-) diff --git a/test/built-ins/Array/prototype/concat/create-species-non-ctor.js b/test/built-ins/Array/prototype/concat/create-species-non-ctor.js index 1095078be4..53a9e2a199 100644 --- a/test/built-ins/Array/prototype/concat/create-species-non-ctor.js +++ b/test/built-ins/Array/prototype/concat/create-species-non-ctor.js @@ -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 = {}; diff --git a/test/built-ins/Array/prototype/filter/create-species-non-ctor.js b/test/built-ins/Array/prototype/filter/create-species-non-ctor.js index 067c433993..aa3b529fb0 100644 --- a/test/built-ins/Array/prototype/filter/create-species-non-ctor.js +++ b/test/built-ins/Array/prototype/filter/create-species-non-ctor.js @@ -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); diff --git a/test/built-ins/Array/prototype/map/create-species-non-ctor.js b/test/built-ins/Array/prototype/map/create-species-non-ctor.js index d448b4ebb8..1f55d4522e 100644 --- a/test/built-ins/Array/prototype/map/create-species-non-ctor.js +++ b/test/built-ins/Array/prototype/map/create-species-non-ctor.js @@ -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); diff --git a/test/built-ins/Array/prototype/slice/create-species-non-ctor.js b/test/built-ins/Array/prototype/slice/create-species-non-ctor.js index 598368184a..4972bb8d1a 100644 --- a/test/built-ins/Array/prototype/slice/create-species-non-ctor.js +++ b/test/built-ins/Array/prototype/slice/create-species-non-ctor.js @@ -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'); diff --git a/test/built-ins/Array/prototype/splice/create-species-non-ctor.js b/test/built-ins/Array/prototype/splice/create-species-non-ctor.js index 0d5ff35bfe..dd949216e1 100644 --- a/test/built-ins/Array/prototype/splice/create-species-non-ctor.js +++ b/test/built-ins/Array/prototype/splice/create-species-non-ctor.js @@ -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'); diff --git a/test/built-ins/RegExp/prototype/toString/S15.10.6.4_A6.js b/test/built-ins/RegExp/prototype/toString/S15.10.6.4_A6.js index 4cdfe4ca82..2dd4ef4018 100644 --- a/test/built-ins/RegExp/prototype/toString/S15.10.6.4_A6.js +++ b/test/built-ins/RegExp/prototype/toString/S15.10.6.4_A6.js @@ -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' +); diff --git a/test/built-ins/RegExp/prototype/toString/S15.10.6.4_A7.js b/test/built-ins/RegExp/prototype/toString/S15.10.6.4_A7.js index faeddca853..ec818f615e 100644 --- a/test/built-ins/RegExp/prototype/toString/S15.10.6.4_A7.js +++ b/test/built-ins/RegExp/prototype/toString/S15.10.6.4_A7.js @@ -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.