@@ -397,13 +397,59 @@ test('jessie: ASI basic', () => {
397397 is ( ast [ 2 ] , 'b' )
398398} )
399399
400+ test ( 'jessie: ASI flat arrays' , ( ) => {
401+ // 2 stmts - both forms should be identical
402+ is ( parse ( 'a;b' ) , [ ';' , 'a' , 'b' ] )
403+ is ( parse ( 'a\nb' ) , [ ';' , 'a' , 'b' ] )
404+
405+ // 3 stmts - flat array, not nested
406+ is ( parse ( 'a;b;c' ) , [ ';' , 'a' , 'b' , 'c' ] )
407+ is ( parse ( 'a\nb\nc' ) , [ ';' , 'a' , 'b' , 'c' ] )
408+ is ( parse ( 'a;b\nc' ) , [ ';' , 'a' , 'b' , 'c' ] )
409+ is ( parse ( 'a\nb;c' ) , [ ';' , 'a' , 'b' , 'c' ] )
410+
411+ // 4 stmts - all variations flat
412+ is ( parse ( 'a;b;c;d' ) , [ ';' , 'a' , 'b' , 'c' , 'd' ] )
413+ is ( parse ( 'a\nb\nc\nd' ) , [ ';' , 'a' , 'b' , 'c' , 'd' ] )
414+ is ( parse ( 'a;b\nc;d' ) , [ ';' , 'a' , 'b' , 'c' , 'd' ] )
415+ } )
416+
400417test ( 'jessie: ASI return' , ( ) => {
401418 const ast = parse ( 'return\nx' )
402419 is ( ast [ 0 ] , ';' )
403420 is ( ast [ 1 ] [ 0 ] , 'return' )
404421 is ( ast [ 2 ] , 'x' )
405422} )
406423
424+ test ( 'jessie: ASI custom precedence' , async ( ) => {
425+ const { prec, parse } = await import ( '../parse.js' )
426+
427+ // Default: ASI at statement level (prec[';'] = 5)
428+ // Newline continues expression when inside higher-precedence context
429+ is ( parse ( 'a + b\nc' ) , [ ';' , [ '+' , 'a' , 'b' ] , 'c' ] )
430+ is ( parse ( 'a\n+ b' ) , [ '+' , 'a' , 'b' ] , 'continuation token binds' )
431+
432+ // Disable ASI and reimport feature fresh
433+ prec . asi = 0
434+ parse . asi = null
435+ await import ( '../feature/asi.js?v=disabled' )
436+ let threw = false
437+ try { parse ( 'a\nb' ) } catch { threw = true }
438+ is ( threw , true , 'asi=0 disables ASI' )
439+
440+ // High precedence: ASI triggers inside expressions
441+ prec . asi = 150
442+ parse . asi = null
443+ await import ( '../feature/asi.js?v=high' )
444+ is ( parse ( 'a + b\nc' ) , [ '+' , 'a' , [ ';' , 'b' , 'c' ] ] , 'ASI inside + rhs' )
445+
446+ // Restore default
447+ delete prec . asi
448+ parse . asi = null
449+ await import ( '../feature/asi.js?v=restore' )
450+ is ( parse ( 'a\nb' ) , [ ';' , 'a' , 'b' ] )
451+ } )
452+
407453// === compile integration ===
408454
409455test ( 'jessie: compile integration' , ( ) => {
0 commit comments