Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/DataView/defined-byteoffset-undefined-bytelength-sab.js

raw
1 // Copyright (C) 2016 the V8 project authors. All rights reserved.
2 // Copyright (C) 2017 Mozilla Corporation. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4
5 /*---
6 es6id: 24.2.2.1
7 esid: sec-dataview-buffer-byteoffset-bytelength
8 description: >
9 Return new instance from defined byteoffset and undefined bytelength
10 info: |
11 24.2.2.1 DataView (buffer, byteOffset, byteLength )
12
13 ...
14 8. If byteLength is either not present or undefined, then
15 a. Let viewByteLength be bufferByteLength - offset.
16 ...
17 17. Return O.
18 features: [SharedArrayBuffer]
19 ---*/
20
21 var sample;
22 var buffer = new SharedArrayBuffer(4);
23
24 sample = new DataView(buffer, 0, undefined);
25 assert.sameValue(sample.byteLength, 4, "sample.byteLength");
26 assert.sameValue(sample.byteOffset, 0, "sample.byteOffset");
27 assert.sameValue(sample.buffer, buffer);
28 assert.sameValue(sample.constructor, DataView);
29 assert.sameValue(Object.getPrototypeOf(sample), DataView.prototype);
30
31 sample = new DataView(buffer, 1, undefined);
32 assert.sameValue(sample.byteLength, 3, "sample.byteLength");
33 assert.sameValue(sample.byteOffset, 1, "sample.byteOffset");
34 assert.sameValue(sample.buffer, buffer);
35 assert.sameValue(sample.constructor, DataView);
36 assert.sameValue(Object.getPrototypeOf(sample), DataView.prototype);
37
38 sample = new DataView(buffer, 2, undefined);
39 assert.sameValue(sample.byteLength, 2, "sample.byteLength");
40 assert.sameValue(sample.byteOffset, 2, "sample.byteOffset");
41 assert.sameValue(sample.buffer, buffer);
42 assert.sameValue(sample.constructor, DataView);
43 assert.sameValue(Object.getPrototypeOf(sample), DataView.prototype);
44
45 sample = new DataView(buffer, 3, undefined);
46 assert.sameValue(sample.byteLength, 1, "sample.byteLength");
47 assert.sameValue(sample.byteOffset, 3, "sample.byteOffset");
48 assert.sameValue(sample.buffer, buffer);
49 assert.sameValue(sample.constructor, DataView);
50 assert.sameValue(Object.getPrototypeOf(sample), DataView.prototype);
51
52 sample = new DataView(buffer, 4, undefined);
53 assert.sameValue(sample.byteLength, 0, "sample.byteLength");
54 assert.sameValue(sample.byteOffset, 4, "sample.byteOffset");
55 assert.sameValue(sample.buffer, buffer);
56 assert.sameValue(sample.constructor, DataView);
57 assert.sameValue(Object.getPrototypeOf(sample), DataView.prototype);