-
Notifications
You must be signed in to change notification settings - Fork 509
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor/test: test for correctness of syntax, not just parsing
- have most of the syntax tests export a function that returns true if the syntax is evaluated correctly, and test that it does in fact return true - just using `true` as something consistent and easy to test for - change the async test to move the side effect before the Promise resolves - not entirely sure why, potentially because of the way the event loop works (race condition), but this was returning false when after and true when before - both work as a side effect, so just have it before
- Loading branch information
Showing
6 changed files
with
29 additions
and
12 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
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,4 +1,4 @@ | ||
// regression test for generators | ||
export function* testGenerator() { | ||
return yield 'blah'; | ||
return yield true; | ||
} |
9 changes: 6 additions & 3 deletions
9
test/e2e/fixtures/build-default/src/syntax/nullish-coalescing.ts
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,9 @@ | ||
// regression test for nullish coalescing syntax | ||
// https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#nullish-coalescing | ||
|
||
const someFunc = () => {}; | ||
const someFalse = false; | ||
const shouldBeFalse = someFalse ?? someFunc(); | ||
export function testNullishCoalescing() { | ||
const someFunc = () => 'some string'; | ||
const someFalse = false; | ||
const shouldBeTrue = !(someFalse ?? someFunc()); | ||
return shouldBeTrue; | ||
} |
7 changes: 5 additions & 2 deletions
7
test/e2e/fixtures/build-default/src/syntax/optional-chaining.ts
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,5 +1,8 @@ | ||
// regression test for optional chaining syntax | ||
// https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#optional-chaining | ||
|
||
const someObj: { someOptionalString?: string } = {}; | ||
const shouldBeBar = someObj?.someOptionalString || 'bar'; | ||
export function testOptionalChaining() { | ||
const someObj: { someOptionalString?: string } = {}; | ||
const shouldBeTrue = someObj?.someOptionalString || true; | ||
return shouldBeTrue; | ||
} |
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 comment was marked as resolved.
Sorry, something went wrong.