-
Notifications
You must be signed in to change notification settings - Fork 459
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add ability to control experimental tests
Add the ability to specify a NAPI_VERSION which limits the tests executed to those supported by that version. As an example tests can be built/run as: npm test --NAPI_VERSION=3 PR-URL: #350 Fixes: #349 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Jinho Bang <zino@chromium.org>
- Loading branch information
Showing
9 changed files
with
129 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
'use strict'; | ||
const buildType = process.config.target_defaults.default_configuration; | ||
const assert = require('assert'); | ||
|
||
test(require(`./build/${buildType}/binding.node`)); | ||
test(require(`./build/${buildType}/binding_noexcept.node`)); | ||
|
||
function test(binding) { | ||
[ | ||
['bigint64', BigInt64Array], | ||
['biguint64', BigUint64Array], | ||
].forEach(([type, Constructor]) => { | ||
try { | ||
const length = 4; | ||
const t = binding.typedarray.createTypedArray(type, length); | ||
assert.ok(t instanceof Constructor); | ||
assert.strictEqual(binding.typedarray.getTypedArrayType(t), type); | ||
assert.strictEqual(binding.typedarray.getTypedArrayLength(t), length); | ||
|
||
t[3] = 11n; | ||
assert.strictEqual(binding.typedarray.getTypedArrayElement(t, 3), 11n); | ||
binding.typedarray.setTypedArrayElement(t, 3, 22n); | ||
assert.strictEqual(binding.typedarray.getTypedArrayElement(t, 3), 22n); | ||
assert.strictEqual(t[3], 22n); | ||
|
||
const b = binding.typedarray.getTypedArrayBuffer(t); | ||
assert.ok(b instanceof ArrayBuffer); | ||
} catch (e) { | ||
console.log(type, Constructor); | ||
throw e; | ||
} | ||
|
||
try { | ||
const length = 4; | ||
const offset = 8; | ||
const b = new ArrayBuffer(offset + 64 * 4); | ||
|
||
const t = binding.typedarray.createTypedArray(type, length, b, offset); | ||
assert.ok(t instanceof Constructor); | ||
assert.strictEqual(binding.typedarray.getTypedArrayType(t), type); | ||
assert.strictEqual(binding.typedarray.getTypedArrayLength(t), length); | ||
|
||
t[3] = 11n; | ||
assert.strictEqual(binding.typedarray.getTypedArrayElement(t, 3), 11n); | ||
binding.typedarray.setTypedArrayElement(t, 3, 22n); | ||
assert.strictEqual(binding.typedarray.getTypedArrayElement(t, 3), 22n); | ||
assert.strictEqual(t[3], 22n); | ||
|
||
assert.strictEqual(binding.typedarray.getTypedArrayBuffer(t), b); | ||
} catch (e) { | ||
console.log(type, Constructor); | ||
throw e; | ||
} | ||
}); | ||
|
||
assert.throws(() => { | ||
binding.typedarray.createInvalidTypedArray(); | ||
}, /Invalid (pointer passed as )?argument/); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters