-
Notifications
You must be signed in to change notification settings - Fork 650
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add parsing support for Flow Enums of bigints - JS changes
Summary: Add parsing support for Flow Enums of bigints - JS changes split out as requested. Reviewed By: SamChou19815 Differential Revision: D56495696 fbshipit-source-id: 1c695a362a6f4d613a3005320c8476f37fba5805
- Loading branch information
1 parent
1e10ba3
commit 0d57cfe
Showing
9 changed files
with
199 additions
and
1 deletion.
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
89 changes: 89 additions & 0 deletions
89
tools/hermes-parser/js/hermes-parser/__tests__/Enum-test.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,89 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow strict-local | ||
* @format | ||
*/ | ||
|
||
import type {AlignmentCase} from '../__test_utils__/alignment-utils'; | ||
|
||
import {expectEspreeAlignment} from '../__test_utils__/alignment-utils'; | ||
import {parseForSnapshot} from '../__test_utils__/parse'; | ||
|
||
describe('Enum', () => { | ||
const testCase: AlignmentCase = { | ||
code: ` | ||
enum T1 { A = 1n, B = 2n} | ||
`, | ||
espree: { | ||
expectToFail: 'espree-exception', | ||
expectedExceptionMessage: `The keyword 'enum' is reserved`, | ||
}, | ||
babel: { | ||
expectToFail: 'babel-exception', | ||
expectedExceptionMessage: 'Unexpected token', | ||
}, | ||
}; | ||
|
||
test('ESTree', () => { | ||
expect(parseForSnapshot(testCase.code)).toMatchInlineSnapshot(` | ||
{ | ||
"body": [ | ||
{ | ||
"body": { | ||
"explicitType": false, | ||
"hasUnknownMembers": false, | ||
"members": [ | ||
{ | ||
"id": { | ||
"name": "A", | ||
"optional": false, | ||
"type": "Identifier", | ||
"typeAnnotation": null, | ||
}, | ||
"init": { | ||
"bigint": "1", | ||
"literalType": "bigint", | ||
"raw": "1n", | ||
"type": "Literal", | ||
"value": 1n, | ||
}, | ||
"type": "EnumBigIntMember", | ||
}, | ||
{ | ||
"id": { | ||
"name": "B", | ||
"optional": false, | ||
"type": "Identifier", | ||
"typeAnnotation": null, | ||
}, | ||
"init": { | ||
"bigint": "2", | ||
"literalType": "bigint", | ||
"raw": "2n", | ||
"type": "Literal", | ||
"value": 2n, | ||
}, | ||
"type": "EnumBigIntMember", | ||
}, | ||
], | ||
"type": "EnumBigIntBody", | ||
}, | ||
"id": { | ||
"name": "T1", | ||
"optional": false, | ||
"type": "Identifier", | ||
"typeAnnotation": null, | ||
}, | ||
"type": "EnumDeclaration", | ||
}, | ||
], | ||
"type": "Program", | ||
} | ||
`); | ||
expectEspreeAlignment(testCase); | ||
}); | ||
}); |
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
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