summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/typedarrays/ArrayBuffer_constructor.html
blob: 7a94bc683aac85ee5eded5583749b8b92e749861 (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
<!DOCTYPE html>
<meta charset="utf-8">
<title>Typed Arrays Test: ArrayBuffer constructor</title>
<link rel="author" title="Intel" href="http://www.intel.com">
<link rel="help" href="https://www.khronos.org/registry/typedarray/specs/latest/#5">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>

var args = [
  /* numbers */
  [NaN, 0], [+Infinity, 0], [-Infinity, 0], [+0, 0], [-0, 0],
  [-0.4, 0], [-0.9, 0], [1.1, 1], [2.9, 2],
  [1, 1], [-0xF1000000, 0],
  /* strings */
  ["1", 1], ["1e2", 100],
  /* null, undefined, booleans */
  [undefined, 0], [null, 0], [false, 0], [true, 1]
];

args.forEach(function (arg, i) {
  test(function () {
    var abuffer = new ArrayBuffer(arg[0]);
    assert_equals(abuffer.byteLength, arg[1]);
  }, "The argument " + format_value(arg[0]) + " should be interpreted as " +
     arg[1] + " for ArrayBuffer constructor." + i);
});

</script>