summaryrefslogtreecommitdiff
path: root/test/addons
diff options
context:
space:
mode:
Diffstat (limited to 'test/addons')
-rw-r--r--test/addons/non-node-context/test-make-buffer.js21
1 files changed, 11 insertions, 10 deletions
diff --git a/test/addons/non-node-context/test-make-buffer.js b/test/addons/non-node-context/test-make-buffer.js
index 9b17fa4ee9..d134f63b77 100644
--- a/test/addons/non-node-context/test-make-buffer.js
+++ b/test/addons/non-node-context/test-make-buffer.js
@@ -9,14 +9,15 @@ const {
// Because the `Buffer` function and its protoype property only (currently)
// exist in a Node.js instance’s main context, trying to create buffers from
// another context throws an exception.
+assert.throws(
+ () => makeBufferInNewContext(),
+ (exception) => {
+ assert.strictEqual(exception.constructor.name, 'Error');
+ assert(!(exception.constructor instanceof Error));
-try {
- makeBufferInNewContext();
-} catch (exception) {
- assert.strictEqual(exception.constructor.name, 'Error');
- assert(!(exception.constructor instanceof Error));
-
- assert.strictEqual(exception.code, 'ERR_BUFFER_CONTEXT_NOT_AVAILABLE');
- assert.strictEqual(exception.message,
- 'Buffer is not available for the current Context');
-}
+ assert.strictEqual(exception.code, 'ERR_BUFFER_CONTEXT_NOT_AVAILABLE');
+ assert.strictEqual(exception.message,
+ 'Buffer is not available for the current Context');
+ return true;
+ }
+);