summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Array/of/return-a-custom-instance.js
blob: 88510b9c7d1b042cd9bb307a70d72c8a4d3bceec (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.
/*---
esid: sec-array.of
description: >
  Returns an instance from a custom constructor.
info: |
  Array.of ( ...items )

  ...
  4. If IsConstructor(C) is true, then
    a. Let A be Construct(C, «len»).
  ...
  11. Return A.
---*/

function Coop() {}

var coop = Array.of.call(Coop, 'Mike', 'Rick', 'Leo');

assert.sameValue(
  coop.length, 3,
  'The value of coop.length is expected to be 3'
);
assert.sameValue(
  coop[0], 'Mike',
  'The value of coop[0] is expected to be "Mike"'
);
assert.sameValue(
  coop[1], 'Rick',
  'The value of coop[1] is expected to be "Rick"'
);
assert.sameValue(
  coop[2], 'Leo',
  'The value of coop[2] is expected to be "Leo"'
);
assert(coop instanceof Coop, 'The result of evaluating (coop instanceof Coop) is expected to be true');

reportCompare(0, 0);