Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/DataView/buffer-does-not-have-arraybuffer-data-throws.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 Throws a TypeError if buffer does not have [[ArrayBufferData]]
9 info: |
10 24.2.2.1 DataView (buffer, byteOffset, byteLength )
11
12 ...
13 2. If Type(buffer) is not Object, throw a TypeError exception.
14 3. If buffer does not have an [[ArrayBufferData]] internal slot, throw a
15 TypeError exception.
16 ...
17 features: [Int8Array]
18 ---*/
19
20 var obj = {
21 valueOf: function() {
22 throw new Test262Error("buffer should be verified before byteOffset");
23 }
24 };
25
26 assert.throws(TypeError, function() {
27 new DataView({}, obj);
28 }, "{}");
29
30 assert.throws(TypeError, function() {
31 new DataView([], obj);
32 }, "[]");
33
34 var ta = new Int8Array();
35 assert.throws(TypeError, function() {
36 new DataView(ta, obj);
37 }, "typedArray instance");
38
39 var other = new DataView(new ArrayBuffer(1), 0);
40 assert.throws(TypeError, function() {
41 new DataView(other, obj);
42 }, "dataView instance");