@@ -128,6 +128,21 @@ test('parse: bad number', t => {
128128 throws ( t => parse ( '.e-1' ) )
129129} )
130130
131+ test ( 'parse: trailing-dot exponent (1.e3)' , t => {
132+ // A trailing dot with no fractional digits, then an exponent, is one numeric
133+ // literal in JS (`1.e3 === 1000`). The lexer currently stops at `1.` (= 1) and
134+ // re-reads `e3` as a member access `(1).e3` → wrong value. These working forms
135+ // are the regression guards; the trailing-dot-exponent ones are the bug.
136+ is ( parse ( '1.5e3' ) , [ , 1500 ] ) // fractional digits present — already correct
137+ is ( parse ( '1.' ) , [ , 1 ] ) // trailing dot, no exponent — already correct
138+ is ( parse ( '1e3' ) , [ , 1000 ] ) // no dot — already correct
139+ is ( parse ( '1.e3' ) , [ , 1000 ] ) // BUG: parses as ['.', [, 1], 'e3']
140+ is ( parse ( '0.e1' ) , [ , 0 ] ) // BUG: ['.', [, 0], 'e1']
141+ is ( parse ( '0.E1' ) , [ , 0 ] ) // BUG: ['.', [, 0], 'E1']
142+ is ( parse ( '1.e-3' ) , [ , 1e-3 ] ) // BUG: ['-', ['.', [, 1], 'e'], [, 3]]
143+ is ( parse ( '1.e+3' ) , [ , 1000 ] ) // BUG: ['+', ['.', [, 1], 'e'], [, 3]]
144+ } )
145+
131146test ( 'parse: intersecting binary' , t => {
132147 is ( parse ( 'a | b' ) , [ '|' , 'a' , 'b' ] , 'a|b' )
133148 is ( parse ( 'a || b' ) , [ '||' , 'a' , 'b' ] , 'a||b' )
0 commit comments