Skip to content

Commit f145982

Browse files
jasnelltargos
authored andcommitted
test: move a couple of tests over to using node:test
PR-URL: #54582 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent e84812c commit f145982

2 files changed

Lines changed: 28 additions & 25 deletions

File tree

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
// Flags: --expose-internals
1+
// Flags: --expose-internals --no-warnings
22
'use strict';
33

4-
constcommon=require('../common');
4+
const{ hasCrypto }=require('../common');
55

66
// This tests that the accessor properties do not raise assertions
77
// when called with incompatible receivers.
88

99
constassert=require('assert');
10+
const{ test }=require('node:test');
1011

1112
// Objects that call StreamBase::AddMethods, when setting up
1213
// their prototype
1314
const{ internalBinding }=require('internal/test/binding');
14-
constTTY=internalBinding('tty_wrap').TTY;
15-
constUDP=internalBinding('udp_wrap').UDP;
15+
const{TTY}=internalBinding('tty_wrap');
16+
const{UDP}=internalBinding('udp_wrap');
1617

17-
{
18-
// Should throw instead of raise assertions
18+
test('Should throw instead of raise assertions',()=>{
1919
assert.throws(()=>{
2020
UDP.prototype.fd;// eslint-disable-line no-unused-expressions
2121
},TypeError);
@@ -36,20 +36,20 @@ const UDP = internalBinding('udp_wrap').UDP;
3636
'typeof property descriptor '+property+' is not \'object\''
3737
);
3838
});
39+
});
3940

40-
if(common.hasCrypto){// eslint-disable-line node-core/crypto-check
41-
// There are accessor properties in crypto too
42-
constcrypto=internalBinding('crypto');
41+
test('There are accessor properties in crypto too',{skip: !hasCrypto},()=>{
42+
// There are accessor properties in crypto too
43+
constcrypto=internalBinding('crypto');// eslint-disable-line node-core/crypto-check
4344

44-
assert.throws(()=>{
45-
// eslint-disable-next-line no-unused-expressions
46-
crypto.SecureContext.prototype._external;
47-
},TypeError);
45+
assert.throws(()=>{
46+
// eslint-disable-next-line no-unused-expressions
47+
crypto.SecureContext.prototype._external;
48+
},TypeError);
4849

49-
assert.strictEqual(
50-
typeofObject.getOwnPropertyDescriptor(
51-
crypto.SecureContext.prototype,'_external'),
52-
'object'
53-
);
54-
}
55-
}
50+
assert.strictEqual(
51+
typeofObject.getOwnPropertyDescriptor(
52+
crypto.SecureContext.prototype,'_external'),
53+
'object'
54+
);
55+
});
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
'use strict';
22
require('../common');
3+
const{ test }=require('node:test');
34

45
// This test ensures Math functions don't fail with an "illegal instruction"
56
// error on ARM devices (primarily on the Raspberry Pi 1)
67
// See https://github.com/nodejs/node/issues/1376
78
// and https://code.google.com/p/v8/issues/detail?id=4019
89

910
// Iterate over all Math functions
10-
Object.getOwnPropertyNames(Math).forEach((functionName)=>{
11-
if(!/[A-Z]/.test(functionName)){
12-
// The function names don't have capital letters.
13-
Math[functionName](-0.5);
14-
}
11+
test('Iterate over all Math functions',()=>{
12+
Object.getOwnPropertyNames(Math).forEach((functionName)=>{
13+
if(!/[A-Z]/.test(functionName)){
14+
// The function names don't have capital letters.
15+
Math[functionName](-0.5);
16+
}
17+
});
1518
});

0 commit comments

Comments
 (0)