not-a-constructor.js 932 B

1234567891011121314151617181920212223242526272829
  1. // Copyright (C) 2020 Rick Waldron. All rights reserved.
  2. // This code is governed by the BSD license found in the LICENSE file.
  3. /*---
  4. esid: sec-ecmascript-standard-built-in-objects
  5. description: >
  6. ArrayBuffer.isView does not implement [[Construct]], is not new-able
  7. info: |
  8. ECMAScript Function Objects
  9. Built-in function objects that are not identified as constructors do not
  10. implement the [[Construct]] internal method unless otherwise specified in
  11. the description of a particular function.
  12. sec-evaluatenew
  13. ...
  14. 7. If IsConstructor(constructor) is false, throw a TypeError exception.
  15. ...
  16. includes: [isConstructor.js]
  17. features: [Reflect.construct, ArrayBuffer, arrow-function]
  18. ---*/
  19. assert.sameValue(isConstructor(ArrayBuffer.isView), false, 'isConstructor(ArrayBuffer.isView) must return false');
  20. assert.throws(TypeError, () => {
  21. new ArrayBuffer.isView();
  22. }, '`new ArrayBuffer.isView()` throws TypeError');