| 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 is not Object |
| 9 |
info: | |
| 10 |
24.2.2.1 DataView (buffer, byteOffset, byteLength ) |
| 11 |
|
| 12 |
1. If NewTarget is undefined, throw a TypeError exception. |
| 13 |
2. If Type(buffer) is not Object, throw a TypeError exception. |
| 14 |
... |
| 15 |
features: [Symbol] |
| 16 |
---*/ |
| 17 |
|
| 18 |
var obj = { |
| 19 |
valueOf: function() { |
| 20 |
throw new Test262Error("buffer should be verified before byteOffset"); |
| 21 |
} |
| 22 |
}; |
| 23 |
|
| 24 |
assert.throws(TypeError, function() { |
| 25 |
new DataView(0, obj); |
| 26 |
}, "0"); |
| 27 |
|
| 28 |
assert.throws(TypeError, function() { |
| 29 |
new DataView(1, obj); |
| 30 |
}, "1"); |
| 31 |
|
| 32 |
assert.throws(TypeError, function() { |
| 33 |
new DataView("", obj); |
| 34 |
}, "the empty string"); |
| 35 |
|
| 36 |
assert.throws(TypeError, function() { |
| 37 |
new DataView("buffer", obj); |
| 38 |
}, "string"); |
| 39 |
|
| 40 |
assert.throws(TypeError, function() { |
| 41 |
new DataView(false, obj); |
| 42 |
}, "false"); |
| 43 |
|
| 44 |
assert.throws(TypeError, function() { |
| 45 |
new DataView(true, obj); |
| 46 |
}, "true"); |
| 47 |
|
| 48 |
assert.throws(TypeError, function() { |
| 49 |
new DataView(NaN, obj); |
| 50 |
}, "NaN"); |
| 51 |
|
| 52 |
assert.throws(TypeError, function() { |
| 53 |
new DataView(Symbol("1"), obj); |
| 54 |
}, "symbol"); |