summaryrefslogtreecommitdiff
path: root/test/built-ins/TypedArray/prototype/byteLength/return-bytelength.js
blob: 51e0556a76fe38dad104a0218b527f63621983f3 (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
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-get-%typedarray%.prototype.bytelength
description: >
  Return value from [[ByteLength]] internal slot
info: |
  22.2.3.2 get %TypedArray%.prototype.byteLength

  ...
  6. Let size be the value of O's [[ByteLength]] internal slot.
  7. Return size.
includes: [testTypedArray.js]
features: [TypedArray]
---*/

testWithTypedArrayConstructors(function(TA) {
  var bytesPerElement = TA.BYTES_PER_ELEMENT;
  var ta1 = new TA();
  assert.sameValue(ta1.byteLength, 0);

  var ta2 = new TA(42);
  assert.sameValue(ta2.byteLength, 42 * bytesPerElement);
});