summaryrefslogtreecommitdiff
path: root/test/built-ins/Reflect/apply/arguments-list-is-not-array-like.js
blob: 1c3620624716066a6fb7303f4f1371105f0327bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 26.1.1
description: >
  Return abrupt if argumentsList is not an ArrayLike object.
info: |
  26.1.1 Reflect.apply ( target, thisArgument, argumentsList )

  ...
  2. Let args be CreateListFromArrayLike(argumentsList).
  3. ReturnIfAbrupt(args).
  ...

  7.3.17 CreateListFromArrayLike (obj [, elementTypes] )

  ...
  3. If Type(obj) is not Object, throw a TypeError exception.
  4. Let len be ToLength(Get(obj, "length")).
  5. ReturnIfAbrupt(len).
  ...
---*/

function fn() {}
var o = {};

Object.defineProperty(o, 'length', {
  get: function() {
    throw new Test262Error();
  }
});

assert.throws(Test262Error, function() {
  Reflect.apply(fn, 1, o);
});

assert.throws(TypeError, function() {
  Reflect.apply(fn, 1, 1);
});