summaryrefslogtreecommitdiff
path: root/test/built-ins/DataView/prototype/getBigUint64/to-boolean-littleendian.js
blob: 4885dfe416f86465e8a97f1dd2e2052f5f8c2d46 (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
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Boolean littleEndian argument coerced in ToBoolean
esid: sec-dataview.prototype.getbiguint64
features: [ArrayBuffer, BigInt, DataView, DataView.prototype.setUint8, Symbol]
---*/

var buffer = new ArrayBuffer(8);
var sample = new DataView(buffer, 0);
sample.setUint8(7, 0xff);
assert.sameValue(sample.getBigUint64(0), 0xffn, "no argument");

assert.sameValue(sample.getBigUint64(0, false), 0xffn);
assert.sameValue(sample.getBigUint64(0, true), 0xff00000000000000n);
assert.sameValue(sample.getBigUint64(0, 0), 0xffn, "ToBoolean: 0 => false");
assert.sameValue(sample.getBigUint64(0, -0), 0xffn, "ToBoolean: -0 => false");
assert.sameValue(sample.getBigUint64(0, 1), 0xff00000000000000n, "ToBoolean: Number != 0 => true");
assert.sameValue(sample.getBigUint64(0, -1), 0xff00000000000000n, "ToBoolean: Number != 0 => true");
assert.sameValue(sample.getBigUint64(0, 0.1), 0xff00000000000000n, "ToBoolean: Number != 0 => true");
assert.sameValue(sample.getBigUint64(0, Infinity), 0xff00000000000000n,
  "ToBoolean: Number != 0 => true");
assert.sameValue(sample.getBigUint64(0, NaN), 0xffn, "ToBoolean: NaN => false");
assert.sameValue(sample.getBigUint64(0, undefined), 0xffn, "ToBoolean: undefined => false");
assert.sameValue(sample.getBigUint64(0, null), 0xffn, "ToBoolean: null => false");
assert.sameValue(sample.getBigUint64(0, ""), 0xffn, "ToBoolean: String .length == 0 => false");
assert.sameValue(sample.getBigUint64(0, "string"), 0xff00000000000000n,
  "ToBoolean: String .length > 0 => true");
assert.sameValue(sample.getBigUint64(0, "false"), 0xff00000000000000n,
  "ToBoolean: String .length > 0 => true");
assert.sameValue(sample.getBigUint64(0, " "), 0xff00000000000000n,
  "ToBoolean: String .length > 0 => true");
assert.sameValue(sample.getBigUint64(0, Symbol("1")), 0xff00000000000000n,
  "ToBoolean: Symbol => true");
assert.sameValue(sample.getBigUint64(0, 0n), 0xffn, "ToBoolean: 0n => false");
assert.sameValue(sample.getBigUint64(0, 1n), 0xff00000000000000n, "ToBoolean: BigInt != 0n => true");
assert.sameValue(sample.getBigUint64(0, []), 0xff00000000000000n, "ToBoolean: any object => true");
assert.sameValue(sample.getBigUint64(0, {}), 0xff00000000000000n, "ToBoolean: any object => true");
assert.sameValue(sample.getBigUint64(0, Object(false)), 0xff00000000000000n,
  "ToBoolean: any object => true; no ToPrimitive");