From c44d41b2d81914cea8d1cd8410ff7ad146ea8776 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Mon, 26 Aug 2024 19:20:32 -0700 Subject: [PATCH] test: move a couple of tests over to using node:test PR-URL: https://github.com/nodejs/node/pull/54582 Reviewed-By: Yagiz Nizipli Reviewed-By: Colin Ihrig --- test/parallel/test-accessor-properties.js | 40 +++++++++---------- .../test-arm-math-illegal-instruction.js | 13 +++--- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/test/parallel/test-accessor-properties.js b/test/parallel/test-accessor-properties.js index ae7919ea318..7b6c041a8d0 100644 --- a/test/parallel/test-accessor-properties.js +++ b/test/parallel/test-accessor-properties.js @@ -1,21 +1,21 @@ -// Flags: --expose-internals +// Flags: --expose-internals --no-warnings 'use strict'; -const common = require('../common'); +const { hasCrypto } = require('../common'); // This tests that the accessor properties do not raise assertions // when called with incompatible receivers. const assert = require('assert'); +const { test } = require('node:test'); // Objects that call StreamBase::AddMethods, when setting up // their prototype const { internalBinding } = require('internal/test/binding'); -const TTY = internalBinding('tty_wrap').TTY; -const UDP = internalBinding('udp_wrap').UDP; +const { TTY } = internalBinding('tty_wrap'); +const { UDP } = internalBinding('udp_wrap'); -{ - // Should throw instead of raise assertions +test('Should throw instead of raise assertions', () => { assert.throws(() => { UDP.prototype.fd; // eslint-disable-line no-unused-expressions }, TypeError); @@ -36,20 +36,20 @@ const UDP = internalBinding('udp_wrap').UDP; 'typeof property descriptor ' + property + ' is not \'object\'' ); }); +}); - if (common.hasCrypto) { // eslint-disable-line node-core/crypto-check - // There are accessor properties in crypto too - const crypto = internalBinding('crypto'); +test('There are accessor properties in crypto too', { skip: !hasCrypto }, () => { + // There are accessor properties in crypto too + const crypto = internalBinding('crypto'); // eslint-disable-line node-core/crypto-check - assert.throws(() => { - // eslint-disable-next-line no-unused-expressions - crypto.SecureContext.prototype._external; - }, TypeError); + assert.throws(() => { + // eslint-disable-next-line no-unused-expressions + crypto.SecureContext.prototype._external; + }, TypeError); - assert.strictEqual( - typeof Object.getOwnPropertyDescriptor( - crypto.SecureContext.prototype, '_external'), - 'object' - ); - } -} + assert.strictEqual( + typeof Object.getOwnPropertyDescriptor( + crypto.SecureContext.prototype, '_external'), + 'object' + ); +}); diff --git a/test/parallel/test-arm-math-illegal-instruction.js b/test/parallel/test-arm-math-illegal-instruction.js index 4bf881d1b38..c4a6ec01ba8 100644 --- a/test/parallel/test-arm-math-illegal-instruction.js +++ b/test/parallel/test-arm-math-illegal-instruction.js @@ -1,5 +1,6 @@ 'use strict'; require('../common'); +const { test } = require('node:test'); // This test ensures Math functions don't fail with an "illegal instruction" // error on ARM devices (primarily on the Raspberry Pi 1) @@ -7,9 +8,11 @@ require('../common'); // and https://code.google.com/p/v8/issues/detail?id=4019 // Iterate over all Math functions -Object.getOwnPropertyNames(Math).forEach((functionName) => { - if (!/[A-Z]/.test(functionName)) { - // The function names don't have capital letters. - Math[functionName](-0.5); - } +test('Iterate over all Math functions', () => { + Object.getOwnPropertyNames(Math).forEach((functionName) => { + if (!/[A-Z]/.test(functionName)) { + // The function names don't have capital letters. + Math[functionName](-0.5); + } + }); });