-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: finish tests for async transform
- Loading branch information
1 parent
e59ea96
commit 75a99b0
Showing
13 changed files
with
242 additions
and
0 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
40 changes: 40 additions & 0 deletions
40
src/lib/tests/expected-transforms/add-yield-after-await-assignment/code.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,40 @@ | ||
import { task } from "svelte-concurrency"; | ||
|
||
/** | ||
* @param {number} val | ||
*/ | ||
function fn(val){ | ||
return val; | ||
} | ||
|
||
/** | ||
* | ||
* @param {TemplateStringsArray} quasi | ||
* @param {string} strings | ||
*/ | ||
function str(quasi, strings){ | ||
|
||
} | ||
|
||
task(async ()=>{ | ||
const assign = await Promise.resolve(); | ||
const array = [await Promise.resolve()]; | ||
const sum = await Promise.resolve(1) + 2; | ||
const sum2 = 2 + await Promise.resolve(1); | ||
const function_call = fn(await Promise.resolve(2)); | ||
const conditional1 = await Promise.resolve(true) ? 1 : 2; | ||
const conditional2 = true ? await Promise.resolve(1) : 2; | ||
const conditional3 = false ? 1: await Promise.resolve(2); | ||
const logical1 = await Promise.resolve(null) ?? 3; | ||
const logical2 = null ?? await Promise.resolve(null); | ||
const logical3 = null || await Promise.resolve(null); | ||
const logical4 = await Promise.resolve(null) || null; | ||
const logical5 = await Promise.resolve(null) && null; | ||
const logical6 = true && await Promise.resolve(null); | ||
const object_expression1 = {awaited: await Promise.resolve(2)}; | ||
const object_expression2 = {awaited: {nested: await Promise.resolve(2)}}; | ||
const object_expression3 = {awaited: {nested: [await Promise.resolve(2)]}}; | ||
const tagged_template = str`something ${await Promise.resolve("")}`; | ||
const template_literal = `something ${await Promise.resolve("")}`; | ||
const unary = !(await Promise.resolve(true)) | ||
}); |
93 changes: 93 additions & 0 deletions
93
src/lib/tests/expected-transforms/add-yield-after-await-assignment/transform.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,93 @@ | ||
import { task } from "svelte-concurrency"; | ||
|
||
function fn(val) { | ||
return val; | ||
} | ||
|
||
function str(quasi, strings) {} | ||
|
||
task(async function* () { | ||
const assign = await Promise.resolve(); | ||
|
||
yield; | ||
|
||
const array = [await Promise.resolve()]; | ||
|
||
yield; | ||
|
||
const sum = await Promise.resolve(1) + 2; | ||
|
||
yield; | ||
|
||
const sum2 = 2 + await Promise.resolve(1); | ||
|
||
yield; | ||
|
||
const function_call = fn(await Promise.resolve(2)); | ||
|
||
yield; | ||
|
||
const conditional1 = await Promise.resolve(true) ? 1 : 2; | ||
|
||
yield; | ||
|
||
const conditional2 = true ? await Promise.resolve(1) : 2; | ||
|
||
yield; | ||
|
||
const conditional3 = false ? 1 : await Promise.resolve(2); | ||
|
||
yield; | ||
|
||
const logical1 = await Promise.resolve(null) ?? 3; | ||
|
||
yield; | ||
|
||
const logical2 = null ?? await Promise.resolve(null); | ||
|
||
yield; | ||
|
||
const logical3 = null || await Promise.resolve(null); | ||
|
||
yield; | ||
|
||
const logical4 = await Promise.resolve(null) || null; | ||
|
||
yield; | ||
|
||
const logical5 = await Promise.resolve(null) && null; | ||
|
||
yield; | ||
|
||
const logical6 = true && await Promise.resolve(null); | ||
|
||
yield; | ||
|
||
const object_expression1 = { awaited: await Promise.resolve(2) }; | ||
|
||
yield; | ||
|
||
const object_expression2 = { | ||
awaited: { nested: await Promise.resolve(2) } | ||
}; | ||
|
||
yield; | ||
|
||
const object_expression3 = { | ||
awaited: { nested: [await Promise.resolve(2)] } | ||
}; | ||
|
||
yield; | ||
|
||
const tagged_template = str`something ${await Promise.resolve("")}`; | ||
|
||
yield; | ||
|
||
const template_literal = `something ${await Promise.resolve("")}`; | ||
|
||
yield; | ||
|
||
const unary = !await Promise.resolve(true); | ||
|
||
yield; | ||
}); |
6 changes: 6 additions & 0 deletions
6
src/lib/tests/expected-transforms/add-yield-after-multiple-await/code.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,6 @@ | ||
import { task } from "svelte-concurrency"; | ||
|
||
task(async ()=>{ | ||
await Promise.resolve(); | ||
await Promise.resolve(); | ||
}); |
8 changes: 8 additions & 0 deletions
8
src/lib/tests/expected-transforms/add-yield-after-multiple-await/transform.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,8 @@ | ||
import { task } from "svelte-concurrency"; | ||
|
||
task(async function* () { | ||
await Promise.resolve(); | ||
yield; | ||
await Promise.resolve(); | ||
yield; | ||
}); |
12 changes: 12 additions & 0 deletions
12
src/lib/tests/expected-transforms/task-aliased-plus-task-from-another-library/code.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,12 @@ | ||
import { task as other_name } from "svelte-concurrency"; | ||
import { task } from "another-library"; | ||
|
||
task(async ()=>{ | ||
await Promise.resolve(); | ||
await Promise.resolve(); | ||
}); | ||
|
||
other_name(async ()=>{ | ||
await Promise.resolve(); | ||
await Promise.resolve(); | ||
}); |
14 changes: 14 additions & 0 deletions
14
src/lib/tests/expected-transforms/task-aliased-plus-task-from-another-library/transform.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,14 @@ | ||
import { task as other_name } from "svelte-concurrency"; | ||
import { task } from "another-library"; | ||
|
||
task(async () => { | ||
await Promise.resolve(); | ||
await Promise.resolve(); | ||
}); | ||
|
||
other_name(async function* () { | ||
await Promise.resolve(); | ||
yield; | ||
await Promise.resolve(); | ||
yield; | ||
}); |
19 changes: 19 additions & 0 deletions
19
src/lib/tests/expected-transforms/task-aliased-plus-task-function/code.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 @@ | ||
import { task as other_name } from "svelte-concurrency"; | ||
|
||
/** | ||
* | ||
* @param {()=>void} fn | ||
*/ | ||
function task(fn){ | ||
fn(); | ||
} | ||
|
||
task(async ()=>{ | ||
await Promise.resolve(); | ||
await Promise.resolve(); | ||
}); | ||
|
||
other_name(async ()=>{ | ||
await Promise.resolve(); | ||
await Promise.resolve(); | ||
}); |
17 changes: 17 additions & 0 deletions
17
src/lib/tests/expected-transforms/task-aliased-plus-task-function/transform.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,17 @@ | ||
import { task as other_name } from "svelte-concurrency"; | ||
|
||
function task(fn) { | ||
fn(); | ||
} | ||
|
||
task(async () => { | ||
await Promise.resolve(); | ||
await Promise.resolve(); | ||
}); | ||
|
||
other_name(async function* () { | ||
await Promise.resolve(); | ||
yield; | ||
await Promise.resolve(); | ||
yield; | ||
}); |
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,6 @@ | ||
import { task as other_name } from "svelte-concurrency"; | ||
|
||
other_name(async ()=>{ | ||
await Promise.resolve(); | ||
await Promise.resolve(); | ||
}); |
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,8 @@ | ||
import { task as other_name } from "svelte-concurrency"; | ||
|
||
other_name(async function* () { | ||
await Promise.resolve(); | ||
yield; | ||
await Promise.resolve(); | ||
yield; | ||
}); |
6 changes: 6 additions & 0 deletions
6
src/lib/tests/expected-transforms/task-from-another-library/code.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,6 @@ | ||
import { task } from "another-library"; | ||
|
||
task(async ()=>{ | ||
await Promise.resolve(); | ||
await Promise.resolve(); | ||
}); |
11 changes: 11 additions & 0 deletions
11
src/lib/tests/expected-transforms/task-not-from-svelte-concurrency/code.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,11 @@ | ||
/** | ||
* @param {()=>void} fn | ||
*/ | ||
function task(fn){ | ||
fn(); | ||
} | ||
|
||
task(async ()=>{ | ||
await Promise.resolve(); | ||
await Promise.resolve(); | ||
}); |