File tree 6 files changed +40
-30
lines changed
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(
47
47
function findUpExpressionStatement ( ) : t . ExpressionStatement | undefined {
48
48
for ( let i = nodeStack . length - 1 ; i >= 0 ; i -- ) {
49
49
const node = nodeStack [ i ]
50
- if ( isFunctionType ( node ) ) return
50
+ if ( isFunctionType ( node ) || node . type === 'BlockStatement' ) return
51
51
if ( node . type === 'ExpressionStatement' ) {
52
52
return node
53
53
}
@@ -80,7 +80,9 @@ export function transformQuansync(
80
80
s . appendLeft ( node . end ! , ')' )
81
81
82
82
const stmt = findUpExpressionStatement ( )
83
- if ( stmt ) prependSemi ( stmt )
83
+ if ( stmt && stmt . start === node . start ) {
84
+ prependSemi ( stmt )
85
+ }
84
86
}
85
87
return
86
88
}
Original file line number Diff line number Diff line change @@ -88,15 +88,6 @@ export const fn7 = quansync(function* () {
88
88
}
89
89
} )
90
90
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
-
100
91
export default async () => {
101
92
await expect (getNumber (1 )).resolves .toBe (1 )
102
93
expect (getNumber .sync (1 )).toBe (1 )
@@ -170,12 +161,25 @@ export default async () => {
170
161
"
171
162
`;
172
163
173
- exports[`transform > ./fixtures/parens .js 1`] = `
164
+ exports[`transform > ./fixtures/semi .js 1`] = `
174
165
"import { quansync } from 'quansync/macro'
175
166
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
178
170
return config
179
171
} )
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
+ } )
180
184
"
181
185
`;
Original file line number Diff line number Diff line change @@ -56,15 +56,6 @@ export const fn7 = quansync(async () => {
56
56
}
57
57
} )
58
58
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
-
68
59
export default async ( ) => {
69
60
await expect ( getNumber ( 1 ) ) . resolves . toBe ( 1 )
70
61
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