node/test/addons-napi/test_dataview/test.js
Ben Noordhuis d9b59def72
build,test: make building addon tests less fragile
* Get rid of recursive `make` when building the node binary.  An earlier
  commit makes GYP write out rules that we can use for proper dependency
  tracking.

* Use module name 'binding' in addons.md and addons-napi/*/binding.gyp.
  This massively simplifies the logic for generating the build rules.

* Check in auto-generated add-on tests from `doc/api/addons.md`.  The
  files change rarely and generating them dynamically causes no end of
  race conditions and special-casing during the build.

PR-URL: https://github.com/nodejs/node/pull/17407
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2018-01-21 02:19:46 +01:00

25 lines
686 B
JavaScript

'use strict';
const common = require('../../common');
const assert = require('assert');
// Testing api calls for arrays
const test_dataview = require(`./build/${common.buildType}/binding`);
// Test for creating dataview
{
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 invalid range
{
const buffer = new ArrayBuffer(128);
assert.throws(() => {
test_dataview.CreateDataView(buffer, 10, 200);
}, RangeError);
}