Skip to content

Commit

Permalink
test: move a couple of tests over to using node:test
Browse files Browse the repository at this point in the history
PR-URL: #54582
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
jasnell authored and targos committed Sep 26, 2024
1 parent 443ecb0 commit 97c23f9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 25 deletions.
40 changes: 20 additions & 20 deletions test/parallel/test-accessor-properties.js
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -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'
);
});
13 changes: 8 additions & 5 deletions test/parallel/test-arm-math-illegal-instruction.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
'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)
// See https://github.com/nodejs/node/issues/1376
// 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);
}
});
});

0 comments on commit 97c23f9

Please sign in to comment.