-
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathtest.js
More file actions
46 lines (38 loc) · 1.2 KB
/
test.js
File metadata and controls
46 lines (38 loc) · 1.2 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"use strict";
// Testing api calls for dataview
const test_dataview = loadAddon("test_dataview");
// Test for creating dataview with ArrayBuffer
{
const buffer = new ArrayBuffer(128);
const template = Reflect.construct(DataView, [buffer]);
const theDataview = test_dataview.CreateDataViewFromJSDataView(template);
assert.ok(
theDataview instanceof DataView,
`Expect ${theDataview} to be a DataView`,
);
}
// Test for creating dataview with SharedArrayBuffer
{
const buffer = new SharedArrayBuffer(128);
const template = new DataView(buffer);
const theDataview = test_dataview.CreateDataViewFromJSDataView(template);
assert.ok(
theDataview instanceof DataView,
`Expect ${theDataview} to be a DataView`,
);
assert.strictEqual(template.buffer, theDataview.buffer);
}
// Test for creating dataview with ArrayBuffer and invalid range
{
const buffer = new ArrayBuffer(128);
assert.throws(() => {
test_dataview.CreateDataView(buffer, 10, 200);
}, RangeError);
}
// Test for creating dataview with SharedArrayBuffer and invalid range
{
const buffer = new SharedArrayBuffer(128);
assert.throws(() => {
test_dataview.CreateDataView(buffer, 10, 200);
}, RangeError);
}