@@ -298,18 +298,22 @@ test.suite(
298298 async ( t ) => {
299299 const { stdout, stderr } = await t . context . executeInRepl (
300300 `9
301- + 3
302- 7
303- - 3
304- 3
305- * 7\n.break
306- 100
307- / 2\n.break
308- 5
309- ** 2\n.break
310- console.log('done!')
311- ` ,
312- { registerHooks : true , waitPattern : 'done!\nundefined\n>' }
301+ + 3
302+ 7
303+ - 3
304+ 3
305+ * 7\n.break
306+ 100
307+ / 2\n.break
308+ 5
309+ ** 2\n.break
310+ console.log('done!')
311+ ` ,
312+ {
313+ registerHooks : true ,
314+ startInternalOptions : { useGlobal : false } ,
315+ waitPattern : 'done!\nundefined\n>' ,
316+ }
313317 ) ;
314318 expect ( stdout ) . not . toContain ( '12' ) ;
315319 expect ( stdout ) . not . toContain ( '4' ) ;
@@ -329,7 +333,11 @@ test.suite(
329333 `(
330334 a
331335 console.log('done!')` ,
332- { registerHooks : true , waitPattern : 'done!\nundefined\n>' }
336+ {
337+ registerHooks : true ,
338+ startInternalOptions : { useGlobal : false } ,
339+ waitPattern : 'done!\nundefined\n>' ,
340+ }
333341 ) ;
334342 expect ( stderr ) . toContain ( "error TS1005: ')' expected." ) ;
335343 expect ( stderr ) . not . toContain ( ';' ) ;
@@ -342,8 +350,12 @@ test.suite(
342350 async ( t ) => {
343351 const { stdout, stderr } = await t . context . executeInRepl (
344352 `)
345- console.log('done!')` ,
346- { registerHooks : true , waitPattern : 'done!\nundefined\n>' }
353+ console.log('done!')` ,
354+ {
355+ registerHooks : true ,
356+ startInternalOptions : { useGlobal : false } ,
357+ waitPattern : 'done!\nundefined\n>' ,
358+ }
347359 ) ;
348360 expect ( stderr ) . toContain (
349361 'error TS1128: Declaration or statement expected.'
@@ -359,16 +371,42 @@ test.suite(
359371 async ( t ) => {
360372 const { stdout, stderr } = await t . context . executeInRepl (
361373 `function foo(a: number) {
362- return a + 1;
363- }
364- foo(
365- 1
366- )` ,
367- { registerHooks : true , waitPattern : '2\n>' }
374+ return a + 1;
375+ }
376+ foo(
377+ 1
378+ )` ,
379+ {
380+ registerHooks : true ,
381+ startInternalOptions : { useGlobal : false } ,
382+ waitPattern : '2\n>' ,
383+ }
368384 ) ;
369385 expect ( stderr ) . toBe ( '' ) ;
370386 expect ( stdout ) . toContain ( '2' ) ;
371387 }
372388 ) ;
389+
390+ // Serial because it's timing-sensitive
391+ test . serial (
392+ 'automatically inserted semicolons do not affect subsequent line numbers' ,
393+ async ( t ) => {
394+ // If first line of input ends in a semicolon, should not add a second semicolon.
395+ // That will cause an extra blank line in the compiled output which will
396+ // offset the stack line number.
397+ const { stdout, stderr } = await t . context . executeInRepl (
398+ `1;
399+ new Error().stack!.split('\\n')[1]
400+ console.log('done!')` ,
401+ {
402+ registerHooks : true ,
403+ startInternalOptions : { useGlobal : false } ,
404+ waitPattern : 'done!' ,
405+ }
406+ ) ;
407+ expect ( stderr ) . toBe ( '' ) ;
408+ expect ( stdout ) . toContain ( ":1:1'\n" ) ;
409+ }
410+ ) ;
373411 }
374412) ;
0 commit comments