Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: move a couple of tests over to using node:test #54582

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? I might understand when there are multiple blocks with many subtests in the same file but I really see no reason to use node:test here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Primarily for consistency in adding structure. I'd flip it around, is there reason to block this change?

Copy link
Member

@lpinca lpinca Aug 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will not block, but I think this is a cosmetic change with the downside of using an additional modules.

Object.getOwnPropertyNames(Math).forEach((functionName) => {
if (!/[A-Z]/.test(functionName)) {
// The function names don't have capital letters.
Math[functionName](-0.5);
}
});
});
Loading