Debian Codegraph @

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

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