-
Notifications
You must be signed in to change notification settings - Fork 503
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: rewrite
AssignmentTargetProperty
- Loading branch information
Showing
12 changed files
with
235 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
crates/rolldown/tests/fixtures/rollup/preserve-for-of-iterable/artifacts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
--- | ||
source: crates/rolldown/tests/common/case.rs | ||
expression: content | ||
input_file: crates/rolldown/tests/fixtures/rollup/preserve-for-of-iterable | ||
--- | ||
# Assets | ||
|
||
## main.mjs | ||
|
||
```js | ||
import { default as assert } from "assert"; | ||
// iterables.js | ||
let dirty; | ||
const zeroToFive = { | ||
[Symbol.iterator](){ | ||
return { | ||
current:0, | ||
last:5, | ||
next(){ | ||
const ret = this.current < this.last ? { | ||
done:false, | ||
value:this.current++ | ||
} : { | ||
done:true | ||
}; | ||
dirty = this.current; | ||
return ret; | ||
} | ||
}; | ||
} | ||
}; | ||
// loops.js | ||
const iterate = iterable => { | ||
for (const value of iterable) { | ||
} | ||
}; | ||
// main.js | ||
assert.equal(dirty, undefined); | ||
iterate(zeroToFive); | ||
assert.equal(dirty, 5); | ||
``` |
20 changes: 20 additions & 0 deletions
20
crates/rolldown/tests/fixtures/rollup/preserve-for-of-iterable/iterables.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
export let dirty; | ||
|
||
export const zeroToFive = { | ||
[Symbol.iterator]() { | ||
return { | ||
current: 0, | ||
last: 5, | ||
next() { | ||
const ret = this.current < this.last | ||
? { done: false, value: this.current++ } | ||
: { done: true }; | ||
|
||
// assert later | ||
dirty = this.current; | ||
|
||
return ret; | ||
} | ||
}; | ||
} | ||
}; |
19 changes: 19 additions & 0 deletions
19
crates/rolldown/tests/fixtures/rollup/preserve-for-of-iterable/loops.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
export const awaitable = async (iterable) => { | ||
for await (const value of iterable) { | ||
} | ||
} | ||
|
||
// This is equivalent to the above 'awaitable' function. | ||
export const equivalent = async (iterable) => { | ||
const iterator = iterable[Symbol.asyncIterator]() | ||
let { done } = await iterator.next() | ||
while (!done) { | ||
({ done } = await iterator.next()) | ||
} | ||
|
||
} | ||
|
||
export const iterate = iterable => { | ||
for (const value of iterable) { | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
crates/rolldown/tests/fixtures/rollup/preserve-for-of-iterable/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import assert from 'assert'; | ||
import { zeroToFive, dirty } from './iterables'; | ||
import { iterate } from './loops'; | ||
|
||
assert.equal(dirty, undefined); | ||
iterate(zeroToFive); | ||
assert.equal(dirty, 5); |
7 changes: 7 additions & 0 deletions
7
crates/rolldown/tests/fixtures/rollup/preserve-for-of-iterable/test.config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"input": { | ||
"external": [ | ||
"assert" | ||
] | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
crates/rolldown/tests/fixtures/rollup/simplify-with-destructuring/artifacts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
source: crates/rolldown/tests/common/case.rs | ||
expression: content | ||
input_file: crates/rolldown/tests/fixtures/rollup/simplify-with-destructuring | ||
--- | ||
# Assets | ||
|
||
## main.mjs | ||
|
||
```js | ||
import { default as assert } from "assert"; | ||
// main.js | ||
let foo, unused; | ||
null,{foo} = { | ||
foo:'bar' | ||
}; | ||
assert.strictEqual(foo, 'bar'); | ||
const assign = () => unused = {foo} = { | ||
foo:'baz' | ||
}; | ||
assign(); | ||
assert.strictEqual(foo, 'baz'); | ||
``` |
9 changes: 9 additions & 0 deletions
9
crates/rolldown/tests/fixtures/rollup/simplify-with-destructuring/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import assert from 'assert'; | ||
|
||
let foo, unused; | ||
null, { foo } = { foo: 'bar' }; | ||
assert.strictEqual(foo, 'bar'); | ||
|
||
const assign = () => unused = { foo } = { foo: 'baz' }; | ||
assign(); | ||
assert.strictEqual(foo, 'baz'); |
7 changes: 7 additions & 0 deletions
7
crates/rolldown/tests/fixtures/rollup/simplify-with-destructuring/test.config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"input": { | ||
"external": [ | ||
"assert" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"failed": 0, | ||
"skipFailed": 655, | ||
"skipFailed": 657, | ||
"skipped": 0, | ||
"passed": 235 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
| | number | | ||
|----| ---- | | ||
| failed | 0| | ||
| skipFailed | 655| | ||
| skipFailed | 657| | ||
| skipped | 0| | ||
| passed | 235| |