瀏覽代碼

Fix Map and Set call validation (#895)

Marko Lahma 4 年之前
父節點
當前提交
2631405dbb
共有 25 個文件被更改,包括 655 次插入12 次删除
  1. 24 0
      Jint.Tests.Test262/test/built-ins/Map/is-a-constructor.js
  2. 27 0
      Jint.Tests.Test262/test/built-ins/Map/iterator-close-failure-after-set-failure.js
  3. 33 0
      Jint.Tests.Test262/test/built-ins/Map/prototype/Symbol.iterator/not-a-constructor.js
  4. 29 0
      Jint.Tests.Test262/test/built-ins/Map/prototype/clear/not-a-constructor.js
  5. 29 0
      Jint.Tests.Test262/test/built-ins/Map/prototype/delete/not-a-constructor.js
  6. 33 0
      Jint.Tests.Test262/test/built-ins/Map/prototype/entries/not-a-constructor.js
  7. 33 0
      Jint.Tests.Test262/test/built-ins/Map/prototype/forEach/not-a-constructor.js
  8. 29 0
      Jint.Tests.Test262/test/built-ins/Map/prototype/get/not-a-constructor.js
  9. 29 0
      Jint.Tests.Test262/test/built-ins/Map/prototype/has/not-a-constructor.js
  10. 29 0
      Jint.Tests.Test262/test/built-ins/Map/prototype/keys/not-a-constructor.js
  11. 29 0
      Jint.Tests.Test262/test/built-ins/Map/prototype/set/not-a-constructor.js
  12. 29 0
      Jint.Tests.Test262/test/built-ins/Map/prototype/values/not-a-constructor.js
  13. 24 0
      Jint.Tests.Test262/test/built-ins/Set/is-a-constructor.js
  14. 33 0
      Jint.Tests.Test262/test/built-ins/Set/prototype/Symbol.iterator/not-a-constructor.js
  15. 29 0
      Jint.Tests.Test262/test/built-ins/Set/prototype/add/not-a-constructor.js
  16. 29 0
      Jint.Tests.Test262/test/built-ins/Set/prototype/clear/not-a-constructor.js
  17. 29 0
      Jint.Tests.Test262/test/built-ins/Set/prototype/delete/not-a-constructor.js
  18. 33 0
      Jint.Tests.Test262/test/built-ins/Set/prototype/entries/not-a-constructor.js
  19. 33 0
      Jint.Tests.Test262/test/built-ins/Set/prototype/forEach/not-a-constructor.js
  20. 29 0
      Jint.Tests.Test262/test/built-ins/Set/prototype/has/not-a-constructor.js
  21. 29 0
      Jint.Tests.Test262/test/built-ins/Set/prototype/values/not-a-constructor.js
  22. 15 0
      Jint.Tests/Runtime/MapTests.cs
  23. 15 0
      Jint.Tests/Runtime/SetTests.cs
  24. 2 6
      Jint/Native/Map/MapConstructor.cs
  25. 2 6
      Jint/Native/Set/SetConstructor.cs

+ 24 - 0
Jint.Tests.Test262/test/built-ins/Map/is-a-constructor.js

@@ -0,0 +1,24 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+  The Map constructor implements [[Construct]]
+info: |
+  IsConstructor ( argument )
+
+  The abstract operation IsConstructor takes argument argument (an ECMAScript language value).
+  It determines if argument is a function object with a [[Construct]] internal method.
+  It performs the following steps when called:
+
+  If Type(argument) is not Object, return false.
+  If argument has a [[Construct]] internal method, return true.
+  Return false.
+includes: [isConstructor.js]
+features: [Reflect.construct, Map]
+---*/
+
+assert.sameValue(isConstructor(Map), true, 'isConstructor(Map) must return true');
+new Map();
+  

+ 27 - 0
Jint.Tests.Test262/test/built-ins/Map/iterator-close-failure-after-set-failure.js

@@ -0,0 +1,27 @@
+// Copyright (C) 2017 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-map-iterable
+description: >
+  The correct error is thrown `Map.prototype.set` throws an error and
+  the IteratorClose throws an error.
+features: [Symbol.iterator]
+---*/
+
+var count = 0;
+var iterable = {};
+iterable[Symbol.iterator] = function() {
+  return {
+    next: function() {
+      return { value: [], done: false };
+    },
+    return: function() {
+        throw new TypeError('ignore');
+    }
+  };
+};
+Map.prototype.set = function() { throw new Test262Error(); }
+
+assert.throws(Test262Error, function() {
+  new Map(iterable);
+});

+ 33 - 0
Jint.Tests.Test262/test/built-ins/Map/prototype/Symbol.iterator/not-a-constructor.js

@@ -0,0 +1,33 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+  Map.prototype[Symbol.iterator] does not implement [[Construct]], is not new-able
+info: |
+  ECMAScript Function Objects
+
+  Built-in function objects that are not identified as constructors do not
+  implement the [[Construct]] internal method unless otherwise specified in
+  the description of a particular function.
+
+  sec-evaluatenew
+
+  ...
+  7. If IsConstructor(constructor) is false, throw a TypeError exception.
+  ...
+includes: [isConstructor.js]
+features: [Reflect.construct, Symbol, Symbol.iterator, Map, arrow-function]
+---*/
+
+assert.sameValue(
+  isConstructor(Map.prototype[Symbol.iterator]),
+  false,
+  'isConstructor(Map.prototype[Symbol.iterator]) must return false'
+);
+
+assert.throws(TypeError, () => {
+  let m = new Map(); new m[Symbol.iterator]();
+}, '`let m = new Map(); new m[Symbol.iterator]()` throws TypeError');
+

+ 29 - 0
Jint.Tests.Test262/test/built-ins/Map/prototype/clear/not-a-constructor.js

@@ -0,0 +1,29 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+  Map.prototype.clear does not implement [[Construct]], is not new-able
+info: |
+  ECMAScript Function Objects
+
+  Built-in function objects that are not identified as constructors do not
+  implement the [[Construct]] internal method unless otherwise specified in
+  the description of a particular function.
+
+  sec-evaluatenew
+
+  ...
+  7. If IsConstructor(constructor) is false, throw a TypeError exception.
+  ...
+includes: [isConstructor.js]
+features: [Reflect.construct, Map, arrow-function]
+---*/
+
+assert.sameValue(isConstructor(Map.prototype.clear), false, 'isConstructor(Map.prototype.clear) must return false');
+
+assert.throws(TypeError, () => {
+  let m = new Map(); new m.clear();
+}, '`let m = new Map(); new m.clear()` throws TypeError');
+

+ 29 - 0
Jint.Tests.Test262/test/built-ins/Map/prototype/delete/not-a-constructor.js

@@ -0,0 +1,29 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+  Map.prototype.delete does not implement [[Construct]], is not new-able
+info: |
+  ECMAScript Function Objects
+
+  Built-in function objects that are not identified as constructors do not
+  implement the [[Construct]] internal method unless otherwise specified in
+  the description of a particular function.
+
+  sec-evaluatenew
+
+  ...
+  7. If IsConstructor(constructor) is false, throw a TypeError exception.
+  ...
+includes: [isConstructor.js]
+features: [Reflect.construct, Map, arrow-function]
+---*/
+
+assert.sameValue(isConstructor(Map.prototype.delete), false, 'isConstructor(Map.prototype.delete) must return false');
+
+assert.throws(TypeError, () => {
+  let m = new Map(); new m.delete();
+}, '`let m = new Map(); new m.delete()` throws TypeError');
+

+ 33 - 0
Jint.Tests.Test262/test/built-ins/Map/prototype/entries/not-a-constructor.js

@@ -0,0 +1,33 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+  Map.prototype.entries does not implement [[Construct]], is not new-able
+info: |
+  ECMAScript Function Objects
+
+  Built-in function objects that are not identified as constructors do not
+  implement the [[Construct]] internal method unless otherwise specified in
+  the description of a particular function.
+
+  sec-evaluatenew
+
+  ...
+  7. If IsConstructor(constructor) is false, throw a TypeError exception.
+  ...
+includes: [isConstructor.js]
+features: [Reflect.construct, Map, arrow-function]
+---*/
+
+assert.sameValue(
+  isConstructor(Map.prototype.entries),
+  false,
+  'isConstructor(Map.prototype.entries) must return false'
+);
+
+assert.throws(TypeError, () => {
+  let m = new Map(); new m.entries();
+}, '`let m = new Map(); new m.entries()` throws TypeError');
+

+ 33 - 0
Jint.Tests.Test262/test/built-ins/Map/prototype/forEach/not-a-constructor.js

@@ -0,0 +1,33 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+  Map.prototype.forEach does not implement [[Construct]], is not new-able
+info: |
+  ECMAScript Function Objects
+
+  Built-in function objects that are not identified as constructors do not
+  implement the [[Construct]] internal method unless otherwise specified in
+  the description of a particular function.
+
+  sec-evaluatenew
+
+  ...
+  7. If IsConstructor(constructor) is false, throw a TypeError exception.
+  ...
+includes: [isConstructor.js]
+features: [Reflect.construct, Map, arrow-function]
+---*/
+
+assert.sameValue(
+  isConstructor(Map.prototype.forEach),
+  false,
+  'isConstructor(Map.prototype.forEach) must return false'
+);
+
+assert.throws(TypeError, () => {
+  let m = new Map(); new m.forEach();
+}, '`let m = new Map(); new m.forEach()` throws TypeError');
+

+ 29 - 0
Jint.Tests.Test262/test/built-ins/Map/prototype/get/not-a-constructor.js

@@ -0,0 +1,29 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+  Map.prototype.get does not implement [[Construct]], is not new-able
+info: |
+  ECMAScript Function Objects
+
+  Built-in function objects that are not identified as constructors do not
+  implement the [[Construct]] internal method unless otherwise specified in
+  the description of a particular function.
+
+  sec-evaluatenew
+
+  ...
+  7. If IsConstructor(constructor) is false, throw a TypeError exception.
+  ...
+includes: [isConstructor.js]
+features: [Reflect.construct, Map, arrow-function]
+---*/
+
+assert.sameValue(isConstructor(Map.prototype.get), false, 'isConstructor(Map.prototype.get) must return false');
+
+assert.throws(TypeError, () => {
+  let m = new Map(); new m.get();
+}, '`let m = new Map(); new m.get()` throws TypeError');
+

+ 29 - 0
Jint.Tests.Test262/test/built-ins/Map/prototype/has/not-a-constructor.js

@@ -0,0 +1,29 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+  Map.prototype.has does not implement [[Construct]], is not new-able
+info: |
+  ECMAScript Function Objects
+
+  Built-in function objects that are not identified as constructors do not
+  implement the [[Construct]] internal method unless otherwise specified in
+  the description of a particular function.
+
+  sec-evaluatenew
+
+  ...
+  7. If IsConstructor(constructor) is false, throw a TypeError exception.
+  ...
+includes: [isConstructor.js]
+features: [Reflect.construct, Map, arrow-function]
+---*/
+
+assert.sameValue(isConstructor(Map.prototype.has), false, 'isConstructor(Map.prototype.has) must return false');
+
+assert.throws(TypeError, () => {
+  let m = new Map(); new m.has();
+}, '`let m = new Map(); new m.has()` throws TypeError');
+

+ 29 - 0
Jint.Tests.Test262/test/built-ins/Map/prototype/keys/not-a-constructor.js

@@ -0,0 +1,29 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+  Map.prototype.keys does not implement [[Construct]], is not new-able
+info: |
+  ECMAScript Function Objects
+
+  Built-in function objects that are not identified as constructors do not
+  implement the [[Construct]] internal method unless otherwise specified in
+  the description of a particular function.
+
+  sec-evaluatenew
+
+  ...
+  7. If IsConstructor(constructor) is false, throw a TypeError exception.
+  ...
+includes: [isConstructor.js]
+features: [Reflect.construct, Map, arrow-function]
+---*/
+
+assert.sameValue(isConstructor(Map.prototype.keys), false, 'isConstructor(Map.prototype.keys) must return false');
+
+assert.throws(TypeError, () => {
+  let m = new Map(); new m.keys();
+}, '`let m = new Map(); new m.keys()` throws TypeError');
+

+ 29 - 0
Jint.Tests.Test262/test/built-ins/Map/prototype/set/not-a-constructor.js

@@ -0,0 +1,29 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+  Map.prototype.set does not implement [[Construct]], is not new-able
+info: |
+  ECMAScript Function Objects
+
+  Built-in function objects that are not identified as constructors do not
+  implement the [[Construct]] internal method unless otherwise specified in
+  the description of a particular function.
+
+  sec-evaluatenew
+
+  ...
+  7. If IsConstructor(constructor) is false, throw a TypeError exception.
+  ...
+includes: [isConstructor.js]
+features: [Reflect.construct, Map, arrow-function]
+---*/
+
+assert.sameValue(isConstructor(Map.prototype.set), false, 'isConstructor(Map.prototype.set) must return false');
+
+assert.throws(TypeError, () => {
+  let m = new Map(); new m.set();
+}, '`let m = new Map(); new m.set()` throws TypeError');
+

+ 29 - 0
Jint.Tests.Test262/test/built-ins/Map/prototype/values/not-a-constructor.js

@@ -0,0 +1,29 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+  Map.prototype.values does not implement [[Construct]], is not new-able
+info: |
+  ECMAScript Function Objects
+
+  Built-in function objects that are not identified as constructors do not
+  implement the [[Construct]] internal method unless otherwise specified in
+  the description of a particular function.
+
+  sec-evaluatenew
+
+  ...
+  7. If IsConstructor(constructor) is false, throw a TypeError exception.
+  ...
+includes: [isConstructor.js]
+features: [Reflect.construct, Map, arrow-function]
+---*/
+
+assert.sameValue(isConstructor(Map.prototype.values), false, 'isConstructor(Map.prototype.values) must return false');
+
+assert.throws(TypeError, () => {
+  let m = new Map(); new m.values();
+}, '`let m = new Map(); new m.values()` throws TypeError');
+

+ 24 - 0
Jint.Tests.Test262/test/built-ins/Set/is-a-constructor.js

@@ -0,0 +1,24 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+  The Set constructor implements [[Construct]]
+info: |
+  IsConstructor ( argument )
+
+  The abstract operation IsConstructor takes argument argument (an ECMAScript language value).
+  It determines if argument is a function object with a [[Construct]] internal method.
+  It performs the following steps when called:
+
+  If Type(argument) is not Object, return false.
+  If argument has a [[Construct]] internal method, return true.
+  Return false.
+includes: [isConstructor.js]
+features: [Reflect.construct, Set]
+---*/
+
+assert.sameValue(isConstructor(Set), true, 'isConstructor(Set) must return true');
+new Set();
+  

+ 33 - 0
Jint.Tests.Test262/test/built-ins/Set/prototype/Symbol.iterator/not-a-constructor.js

@@ -0,0 +1,33 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+  Set.prototype[Symbol.iterator] does not implement [[Construct]], is not new-able
+info: |
+  ECMAScript Function Objects
+
+  Built-in function objects that are not identified as constructors do not
+  implement the [[Construct]] internal method unless otherwise specified in
+  the description of a particular function.
+
+  sec-evaluatenew
+
+  ...
+  7. If IsConstructor(constructor) is false, throw a TypeError exception.
+  ...
+includes: [isConstructor.js]
+features: [Reflect.construct, Symbol, Symbol.iterator, Set, arrow-function]
+---*/
+
+assert.sameValue(
+  isConstructor(Set.prototype[Symbol.iterator]),
+  false,
+  'isConstructor(Set.prototype[Symbol.iterator]) must return false'
+);
+
+assert.throws(TypeError, () => {
+  let s = new Set([]); new s[Symbol.iterator]();
+}, '`let s = new Set([]); new s[Symbol.iterator]()` throws TypeError');
+

+ 29 - 0
Jint.Tests.Test262/test/built-ins/Set/prototype/add/not-a-constructor.js

@@ -0,0 +1,29 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+  Set.prototype.add does not implement [[Construct]], is not new-able
+info: |
+  ECMAScript Function Objects
+
+  Built-in function objects that are not identified as constructors do not
+  implement the [[Construct]] internal method unless otherwise specified in
+  the description of a particular function.
+
+  sec-evaluatenew
+
+  ...
+  7. If IsConstructor(constructor) is false, throw a TypeError exception.
+  ...
+includes: [isConstructor.js]
+features: [Reflect.construct, Set, arrow-function]
+---*/
+
+assert.sameValue(isConstructor(Set.prototype.add), false, 'isConstructor(Set.prototype.add) must return false');
+
+assert.throws(TypeError, () => {
+  let s = new Set([]); new s.add();
+}, '`let s = new Set([]); new s.add()` throws TypeError');
+

+ 29 - 0
Jint.Tests.Test262/test/built-ins/Set/prototype/clear/not-a-constructor.js

@@ -0,0 +1,29 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+  Set.prototype.clear does not implement [[Construct]], is not new-able
+info: |
+  ECMAScript Function Objects
+
+  Built-in function objects that are not identified as constructors do not
+  implement the [[Construct]] internal method unless otherwise specified in
+  the description of a particular function.
+
+  sec-evaluatenew
+
+  ...
+  7. If IsConstructor(constructor) is false, throw a TypeError exception.
+  ...
+includes: [isConstructor.js]
+features: [Reflect.construct, Set, arrow-function]
+---*/
+
+assert.sameValue(isConstructor(Set.prototype.clear), false, 'isConstructor(Set.prototype.clear) must return false');
+
+assert.throws(TypeError, () => {
+  let s = new Set([]); new s.clear();
+}, '`let s = new Set([]); new s.clear()` throws TypeError');
+

+ 29 - 0
Jint.Tests.Test262/test/built-ins/Set/prototype/delete/not-a-constructor.js

@@ -0,0 +1,29 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+  Set.prototype.delete does not implement [[Construct]], is not new-able
+info: |
+  ECMAScript Function Objects
+
+  Built-in function objects that are not identified as constructors do not
+  implement the [[Construct]] internal method unless otherwise specified in
+  the description of a particular function.
+
+  sec-evaluatenew
+
+  ...
+  7. If IsConstructor(constructor) is false, throw a TypeError exception.
+  ...
+includes: [isConstructor.js]
+features: [Reflect.construct, Set, arrow-function]
+---*/
+
+assert.sameValue(isConstructor(Set.prototype.delete), false, 'isConstructor(Set.prototype.delete) must return false');
+
+assert.throws(TypeError, () => {
+  let s = new Set([]); new s.delete();
+}, '`let s = new Set([]); new s.delete()` throws TypeError');
+

+ 33 - 0
Jint.Tests.Test262/test/built-ins/Set/prototype/entries/not-a-constructor.js

@@ -0,0 +1,33 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+  Set.prototype.entries does not implement [[Construct]], is not new-able
+info: |
+  ECMAScript Function Objects
+
+  Built-in function objects that are not identified as constructors do not
+  implement the [[Construct]] internal method unless otherwise specified in
+  the description of a particular function.
+
+  sec-evaluatenew
+
+  ...
+  7. If IsConstructor(constructor) is false, throw a TypeError exception.
+  ...
+includes: [isConstructor.js]
+features: [Reflect.construct, Set, arrow-function]
+---*/
+
+assert.sameValue(
+  isConstructor(Set.prototype.entries),
+  false,
+  'isConstructor(Set.prototype.entries) must return false'
+);
+
+assert.throws(TypeError, () => {
+  let s = new Set([]); new s.entries();
+}, '`let s = new Set([]); new s.entries()` throws TypeError');
+

+ 33 - 0
Jint.Tests.Test262/test/built-ins/Set/prototype/forEach/not-a-constructor.js

@@ -0,0 +1,33 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+  Set.prototype.forEach does not implement [[Construct]], is not new-able
+info: |
+  ECMAScript Function Objects
+
+  Built-in function objects that are not identified as constructors do not
+  implement the [[Construct]] internal method unless otherwise specified in
+  the description of a particular function.
+
+  sec-evaluatenew
+
+  ...
+  7. If IsConstructor(constructor) is false, throw a TypeError exception.
+  ...
+includes: [isConstructor.js]
+features: [Reflect.construct, Set, arrow-function]
+---*/
+
+assert.sameValue(
+  isConstructor(Set.prototype.forEach),
+  false,
+  'isConstructor(Set.prototype.forEach) must return false'
+);
+
+assert.throws(TypeError, () => {
+  let s = new Set([]); new s.forEach(() => {});
+}, '`let s = new Set([]); new s.forEach(() => {})` throws TypeError');
+

+ 29 - 0
Jint.Tests.Test262/test/built-ins/Set/prototype/has/not-a-constructor.js

@@ -0,0 +1,29 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+  Set.prototype.has does not implement [[Construct]], is not new-able
+info: |
+  ECMAScript Function Objects
+
+  Built-in function objects that are not identified as constructors do not
+  implement the [[Construct]] internal method unless otherwise specified in
+  the description of a particular function.
+
+  sec-evaluatenew
+
+  ...
+  7. If IsConstructor(constructor) is false, throw a TypeError exception.
+  ...
+includes: [isConstructor.js]
+features: [Reflect.construct, Set, arrow-function]
+---*/
+
+assert.sameValue(isConstructor(Set.prototype.has), false, 'isConstructor(Set.prototype.has) must return false');
+
+assert.throws(TypeError, () => {
+  let s = new Set([]); new s.has();
+}, '`let s = new Set([]); new s.has()` throws TypeError');
+

+ 29 - 0
Jint.Tests.Test262/test/built-ins/Set/prototype/values/not-a-constructor.js

@@ -0,0 +1,29 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+  Set.prototype.values does not implement [[Construct]], is not new-able
+info: |
+  ECMAScript Function Objects
+
+  Built-in function objects that are not identified as constructors do not
+  implement the [[Construct]] internal method unless otherwise specified in
+  the description of a particular function.
+
+  sec-evaluatenew
+
+  ...
+  7. If IsConstructor(constructor) is false, throw a TypeError exception.
+  ...
+includes: [isConstructor.js]
+features: [Reflect.construct, Set, arrow-function]
+---*/
+
+assert.sameValue(isConstructor(Set.prototype.values), false, 'isConstructor(Set.prototype.values) must return false');
+
+assert.throws(TypeError, () => {
+  let s = new Set([]); new s.values();
+}, '`let s = new Set([]); new s.values()` throws TypeError');
+

+ 15 - 0
Jint.Tests/Runtime/MapTests.cs

@@ -0,0 +1,15 @@
+using Jint.Runtime;
+using Xunit;
+
+namespace Jint.Tests.Runtime
+{
+    public class MapTests
+    {
+        [Fact]
+        public void ShouldThrowWhenCalledWithoutNew()
+        {
+            var e = Assert.Throws<JavaScriptException>(() => new Engine().Execute("const m = new Map(); Map.call(m,[]);"));
+            Assert.Equal("Constructor Map requires 'new'", e.Message);
+        }
+    }
+}

+ 15 - 0
Jint.Tests/Runtime/SetTests.cs

@@ -0,0 +1,15 @@
+using Jint.Runtime;
+using Xunit;
+
+namespace Jint.Tests.Runtime
+{
+    public class SetTests
+    {
+        [Fact]
+        public void ShouldThrowWhenCalledWithoutNew()
+        {
+            var e = Assert.Throws<JavaScriptException>(() => new Engine().Execute("const m = new Set(); Set.call(m,[]);"));
+            Assert.Equal("Constructor Set requires 'new'", e.Message);
+        }
+    }
+}

+ 2 - 6
Jint/Native/Map/MapConstructor.cs

@@ -54,12 +54,8 @@ namespace Jint.Native.Map
 
         public override JsValue Call(JsValue thisObject, JsValue[] arguments)
         {
-            if (thisObject.IsUndefined())
-            {
-                ExceptionHelper.ThrowTypeError(_engine, "Constructor Map requires 'new'");
-            }
-
-            return Construct(arguments, thisObject);
+            ExceptionHelper.ThrowTypeError(_engine, "Constructor Map requires 'new'");
+            return null;
         }
 
         /// <summary>

+ 2 - 6
Jint/Native/Set/SetConstructor.cs

@@ -54,12 +54,8 @@ namespace Jint.Native.Set
 
         public override JsValue Call(JsValue thisObject, JsValue[] arguments)
         {
-            if (thisObject.IsUndefined())
-            {
-                ExceptionHelper.ThrowTypeError(_engine, "Constructor Set requires 'new'");
-            }
-
-            return Construct(arguments, thisObject);
+            ExceptionHelper.ThrowTypeError(_engine, "Constructor Set requires 'new'");
+            return null;
         }
 
         /// <summary>