Debian Codegraph @

js/src/tests/test262/built-ins/Reflect/construct/arguments-list-is-not-array-like.js

raw
1 // Copyright (C) 2015 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 es6id: 26.1.2
5 description: >
6 Return abrupt if argumentsList is not an ArrayLike object.
7 info: |
8 26.1.2 Reflect.construct ( target, argumentsList [, newTarget] )
9
10 ...
11 4. Let args be CreateListFromArrayLike(argumentsList).
12 5. ReturnIfAbrupt(args).
13 ...
14
15 7.3.17 CreateListFromArrayLike (obj [, elementTypes] )
16
17 ...
18 3. If Type(obj) is not Object, throw a TypeError exception.
19 4. Let len be ToLength(Get(obj, "length")).
20 5. ReturnIfAbrupt(len).
21 ...
22 features: [Reflect, Reflect.construct]
23 ---*/
24
25 function fn() {}
26 var o = {};
27
28 Object.defineProperty(o, 'length', {
29 get: function() {
30 throw new Test262Error();
31 }
32 });
33
34 assert.throws(Test262Error, function() {
35 Reflect.construct(fn, o);
36 });
37
38 assert.throws(TypeError, function() {
39 Reflect.construct(fn, 1);
40 });
41
42 reportCompare(0, 0);