2017-07-19 22:20:43 +02:00
|
|
|
'use strict';
|
|
|
|
const common = require('../../common');
|
|
|
|
const assert = require('assert');
|
|
|
|
|
|
|
|
// Testing api calls for arrays
|
2018-01-23 11:49:25 +01:00
|
|
|
const test_dataview = require(`./build/${common.buildType}/test_dataview`);
|
2017-07-19 22:20:43 +02:00
|
|
|
|
2017-12-26 15:20:39 +01:00
|
|
|
// Test for creating dataview
|
|
|
|
{
|
|
|
|
const buffer = new ArrayBuffer(128);
|
|
|
|
const template = Reflect.construct(DataView, [buffer]);
|
2017-07-19 22:20:43 +02:00
|
|
|
|
2017-12-26 15:20:39 +01:00
|
|
|
const theDataview = test_dataview.CreateDataViewFromJSDataView(template);
|
|
|
|
assert.ok(theDataview instanceof DataView,
|
|
|
|
`Expect ${theDataview} to be a DataView`);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test for creating dataview with invalid range
|
|
|
|
{
|
|
|
|
const buffer = new ArrayBuffer(128);
|
|
|
|
assert.throws(() => {
|
|
|
|
test_dataview.CreateDataView(buffer, 10, 200);
|
|
|
|
}, RangeError);
|
|
|
|
}
|