summaryrefslogtreecommitdiff
path: root/test/built-ins/DataView/prototype/setBigInt64/set-values-return-undefined.js
blob: a92ede6c6992447fb0a83ad869578e2a801b3924 (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
40
41
42
43
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-dataview.prototype.setbigint64
description: >
  Set values and return undefined
includes: [byteConversionValues.js]
features: [DataView, ArrayBuffer, BigInt, arrow-function]
---*/

var buffer = new ArrayBuffer(8);
var sample = new DataView(buffer, 0);

var values = byteConversionValues.values;

values.forEach(function(value, i) {
  if (value === undefined) {
    assert.throws(TypeError,
                  () => sample.setBigInt64(0, BigInt(value), false),
                  "value: " + value);
    return;
  } else if (!Number.isInteger(value) || value > 9007199254740991) {
    assert.throws(RangeError,
                  () => sample.setBigInt64(0, BigInt(value), false),
                  "value " + value);
    return;
  }

  var result = sample.setBigInt64(0, BigInt(value), false);

  assert.sameValue(
    sample.getBigInt64(0),
    BigInt(value),
    "value: " + value
  );

  assert.sameValue(
    result,
    undefined,
    "return is undefined, value: " + value
  );
});