File tree Expand file tree Collapse file tree 6 files changed +40
-30
lines changed
Expand file tree Collapse file tree 6 files changed +40
-30
lines changed Original file line number Diff line number Diff line change 1- tests /fixtures /basic .js
1+ tests /fixtures /semi .js
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ export function transformQuansync(
4747 function findUpExpressionStatement ( ) : t . ExpressionStatement | undefined {
4848 for ( let i = nodeStack . length - 1 ; i >= 0 ; i -- ) {
4949 const node = nodeStack [ i ]
50- if ( isFunctionType ( node ) ) return
50+ if ( isFunctionType ( node ) || node . type === 'BlockStatement' ) return
5151 if ( node . type === 'ExpressionStatement' ) {
5252 return node
5353 }
@@ -80,7 +80,9 @@ export function transformQuansync(
8080 s . appendLeft ( node . end ! , ')' )
8181
8282 const stmt = findUpExpressionStatement ( )
83- if ( stmt ) prependSemi ( stmt )
83+ if ( stmt && stmt . start === node . start ) {
84+ prependSemi ( stmt )
85+ }
8486 }
8587 return
8688 }
Original file line number Diff line number Diff line change @@ -88,15 +88,6 @@ export const fn7 = quansync(function* () {
8888 }
8989} )
9090
91- quansync(function* () {
92- ;! (yield 1 )
93- ;' ' + (yield 1 )
94- ;false && (yield 1 )
95- fn7 ()
96- ;(yield 1 ) < (yield 10 )
97- const x = (yield 1 ) < (yield 10 )
98- } )
99-
10091export default async () => {
10192 await expect (getNumber (1 )).resolves .toBe (1 )
10293 expect (getNumber .sync (1 )).toBe (1 )
@@ -170,12 +161,25 @@ export default async () => {
170161"
171162`;
172163
173- exports[`transform > ./fixtures/parens .js 1`] = `
164+ exports[`transform > ./fixtures/semi .js 1`] = `
174165"import { quansync } from 'quansync/macro'
175166
176- const parens = quansync(function* (obj) {
177- const config = yield (obj + 1 )
167+ quansync(function* (obj) {
168+ let config = yield (obj + 1 )
169+ if (true ) config = (yield 10 ) || 10
178170 return config
179171} )
172+
173+ quansync(function* () {
174+ ! (yield 1 )
175+ ' ' + (yield 1 )
176+ false && (yield 1 )
177+ fn ()
178+ ;(yield 1 ) < (yield 10 )
179+ const x = (yield 1 ) < (yield 10 )
180+
181+ ;[]
182+ [yield 10 ]
183+ } )
180184"
181185`;
Original file line number Diff line number Diff line change @@ -56,15 +56,6 @@ export const fn7 = quansync(async () => {
5656 }
5757} )
5858
59- quansync ( async ( ) => {
60- ! await 1
61- '' + await 1
62- false && await 1
63- fn7 ( )
64- await 1 < await 10
65- const x = await 1 < await 10
66- } )
67-
6859export default async ( ) => {
6960 await expect ( getNumber ( 1 ) ) . resolves . toBe ( 1 )
7061 expect ( getNumber . sync ( 1 ) ) . toBe ( 1 )
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ import { quansync } from 'quansync/macro'
2+
3+ quansync ( async ( obj ) => {
4+ let config = await ( obj + 1 )
5+ if ( true ) config = await 10 || 10
6+ return config
7+ } )
8+
9+ quansync ( async ( ) => {
10+ ! await 1
11+ '' + await 1
12+ false && await 1
13+ fn ( )
14+ await 1 < await 10
15+ const x = await 1 < await 10
16+
17+ ; [ ]
18+ [ await 10 ]
19+ } )
You can’t perform that action at this time.
0 commit comments