1- // Flags: --expose-internals
1+ // Flags: --expose-internals --no-warnings
22'use strict' ;
33
4- const common = 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
99const assert = require ( 'assert' ) ;
10+ const { test } = require ( 'node:test' ) ;
1011
1112// Objects that call StreamBase::AddMethods, when setting up
1213// their prototype
1314const { internalBinding } = require ( 'internal/test/binding' ) ;
14- const TTY = internalBinding ( 'tty_wrap' ) . TTY ;
15- const UDP = 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- const crypto = internalBinding ( 'crypto' ) ;
41+ test ( 'There are accessor properties in crypto too' , { skip : ! hasCrypto } , ( ) => {
42+ // There are accessor properties in crypto too
43+ const crypto = internalBinding ( 'crypto' ) ;
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- typeof Object . getOwnPropertyDescriptor (
51- crypto . SecureContext . prototype , '_external' ) ,
52- 'object'
53- ) ;
54- }
55- }
50+ assert . strictEqual (
51+ typeof Object . getOwnPropertyDescriptor (
52+ crypto . SecureContext . prototype , '_external' ) ,
53+ 'object'
54+ ) ;
55+ } ) ;
0 commit comments