@@ -44,181 +44,3 @@ import "./test/vm";
4444import "./test/wasi" ;
4545import "./test/worker_threads" ;
4646import "./test/zlib" ;
47-
48- import * as http from "node:http" ;
49- import * as http2 from "node:http2" ;
50- import * as https from "node:https" ;
51- import * as inspector from "node:inspector" ;
52- import * as net from "node:net" ;
53- import * as stream from "node:stream" ;
54- import * as trace_events from "node:trace_events" ;
55- import * as url from "node:url" ;
56-
57- //////////////////////////////////////////////////////
58- /// Https tests : https://nodejs.org/api/https.html ///
59- //////////////////////////////////////////////////////
60-
61- {
62- let agent : https . Agent = new https . Agent ( {
63- keepAlive : true ,
64- keepAliveMsecs : 10000 ,
65- maxSockets : Infinity ,
66- maxFreeSockets : 256 ,
67- maxCachedSessions : 100 ,
68- timeout : 15000 ,
69- family : 4 ,
70- } ) ;
71-
72- agent = https . globalAgent ;
73-
74- let sockets : NodeJS . ReadOnlyDict < net . Socket [ ] > = agent . sockets ;
75- sockets = agent . freeSockets ;
76-
77- https . request ( {
78- agent : false ,
79- } ) ;
80- https . request ( {
81- agent,
82- } ) ;
83- https . request ( {
84- agent : undefined ,
85- } ) ;
86-
87- https . get ( "http://www.example.com/xyz" ) ;
88- https . request ( "http://www.example.com/xyz" ) ;
89-
90- https . get ( "http://www.example.com/xyz" , ( res : http . IncomingMessage ) : void => { } ) ;
91- https . request ( "http://www.example.com/xyz" , ( res : http . IncomingMessage ) : void => { } ) ;
92-
93- https . get ( new url . URL ( "http://www.example.com/xyz" ) ) ;
94- https . request ( new url . URL ( "http://www.example.com/xyz" ) ) ;
95-
96- https . get ( new url . URL ( "http://www.example.com/xyz" ) , ( res : http . IncomingMessage ) : void => { } ) ;
97- https . request ( new url . URL ( "http://www.example.com/xyz" ) , ( res : http . IncomingMessage ) : void => { } ) ;
98-
99- const opts : https . RequestOptions = {
100- path : "/some/path" ,
101- } ;
102- https . get ( new url . URL ( "http://www.example.com" ) , opts ) ;
103- https . request ( new url . URL ( "http://www.example.com" ) , opts ) ;
104- https . get ( new url . URL ( "http://www.example.com/xyz" ) , opts , ( res : http . IncomingMessage ) : void => { } ) ;
105- https . request ( new url . URL ( "http://www.example.com/xyz" ) , opts , ( res : http . IncomingMessage ) : void => { } ) ;
106-
107- https . globalAgent . options . ca = [ ] ;
108-
109- {
110- function reqListener ( req : http . IncomingMessage , res : http . ServerResponse ) : void { }
111-
112- class MyIncomingMessage extends http . IncomingMessage {
113- foo : number ;
114- }
115-
116- class MyServerResponse < Request extends http . IncomingMessage = http . IncomingMessage >
117- extends http . ServerResponse < Request >
118- {
119- foo : string ;
120- }
121-
122- let server : https . Server ;
123-
124- server = new https . Server ( ) ;
125- server = new https . Server ( reqListener ) ;
126- server = new https . Server ( { IncomingMessage : MyIncomingMessage } ) ;
127-
128- server = new https . Server ( {
129- IncomingMessage : MyIncomingMessage ,
130- ServerResponse : MyServerResponse ,
131- } , reqListener ) ;
132-
133- server = https . createServer ( ) ;
134- server = https . createServer ( reqListener ) ;
135- server = https . createServer ( { IncomingMessage : MyIncomingMessage } ) ;
136- server = https . createServer ( { ServerResponse : MyServerResponse } , reqListener ) ;
137-
138- const timeout : number = server . timeout ;
139- const listening : boolean = server . listening ;
140- const keepAliveTimeout : number = server . keepAliveTimeout ;
141- const maxHeadersCount : number | null = server . maxHeadersCount ;
142- const headersTimeout : number = server . headersTimeout ;
143- server . setTimeout ( ) . setTimeout ( 1000 ) . setTimeout ( ( ) => { } ) . setTimeout ( 100 , ( ) => { } ) ;
144- }
145- }
146-
147- /////////////////////////////////////////////////////////
148- /// Errors Tests : https://nodejs.org/api/errors.html ///
149- /////////////////////////////////////////////////////////
150-
151- {
152- {
153- Error . stackTraceLimit = Infinity ;
154- }
155- {
156- const myObject = { } ;
157- Error . captureStackTrace ( myObject ) ;
158- }
159- {
160- const frames : NodeJS . CallSite [ ] = [ ] ;
161- Error . prepareStackTrace ! ( new Error ( ) , frames ) ;
162- }
163- {
164- const frame : NodeJS . CallSite = null ! ;
165- const frameThis : unknown = frame . getThis ( ) ;
166- const typeName : string | null = frame . getTypeName ( ) ;
167- const func : Function | undefined = frame . getFunction ( ) ;
168- const funcName : string | null = frame . getFunctionName ( ) ;
169- const meth : string | null = frame . getMethodName ( ) ;
170- const fname : string | undefined = frame . getFileName ( ) ;
171- const lineno : number | null = frame . getLineNumber ( ) ;
172- const colno : number | null = frame . getColumnNumber ( ) ;
173- const evalOrigin : string | undefined = frame . getEvalOrigin ( ) ;
174- const isTop : boolean = frame . isToplevel ( ) ;
175- const isEval : boolean = frame . isEval ( ) ;
176- const isNative : boolean = frame . isNative ( ) ;
177- const isConstr : boolean = frame . isConstructor ( ) ;
178- }
179- }
180-
181- /*****************************************************************************
182- * *
183- * The following tests are the modules not mentioned in document but existed *
184- * *
185- *****************************************************************************/
186-
187- ///////////////////////////////////////////////////////////
188- /// Trace Events Tests ///
189- ///////////////////////////////////////////////////////////
190-
191- {
192- const enabledCategories : string | undefined = trace_events . getEnabledCategories ( ) ;
193- const tracing : trace_events . Tracing = trace_events . createTracing ( { categories : [ "node" , "v8" ] } ) ;
194- const categories : string = tracing . categories ;
195- const enabled : boolean = tracing . enabled ;
196- tracing . enable ( ) ;
197- tracing . disable ( ) ;
198- }
199-
200- ////////////////////////////////////////////////////
201- /// Node.js ESNEXT Support
202- ////////////////////////////////////////////////////
203-
204- {
205- const s = "foo" ;
206- const s1 : string = s . trimLeft ( ) ;
207- const s2 : string = s . trimRight ( ) ;
208- const s3 : string = s . trimStart ( ) ;
209- const s4 : string = s . trimEnd ( ) ;
210- }
211-
212- ////////////////////////////////////////////////////
213- /// Node.js http2 tests
214- ////////////////////////////////////////////////////
215-
216- {
217- http2 . connect ( "https://foo.com" , {
218- createConnection : ( authority , option ) => {
219- authority ; // $ExpectType URL
220- option ; // $ExpectType SessionOptions
221- return new stream . Duplex ( ) ;
222- } ,
223- } ) ;
224- }
0 commit comments