Skip to content

Commit

Permalink
Fix testsuite runner for new Flow names
Browse files Browse the repository at this point in the history
Summary:
Flow changed some names of AST nodes and properties.
Rename in the testsuite for now.

Reviewed By: pieterv

Differential Revision: D44099347

fbshipit-source-id: e3370ffa8bb3d7e83005b00f8144c9939f4bced0
  • Loading branch information
avp authored and facebook-github-bot committed Mar 30, 2023
1 parent 9029f26 commit 3ff366e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions utils/testsuite/esprima_test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class TestStatus(enum.IntEnum):
"BooleanLiteral",
"StringLiteral",
"NumericLiteral",
"BigIntLiteral",
"RegExpLiteral",
"JSXStringLiteral",
}
Expand Down Expand Up @@ -126,9 +127,23 @@ def process_hermes_ast(self, ast):
del ast["directive"]
if ast["type"] == "Identifier" and ast["name"] == "this":
del ast["optional"]
if ast["type"] == "PrivateName":
ast = ast["id"]
ast["type"] = "PrivateIdentifier"
if ast["type"] == "ClassPrivateProperty":
ast["key"]["type"] = "PrivateIdentifier"
ast["computed"] = False
ast["static"] = False
if ast["type"] == "ClassProperty" or ast["type"] == "ClassPrivateProperty":
if not ast["optional"]:
del ast["optional"]
ast["type"] = "PropertyDefinition"
if ast["type"] == "TupleTypeAnnotation":
ast["elementTypes"] = ast["types"]
del ast["types"]
if ast["type"] == "TupleTypeLabeledElement":
if not ast["optional"]:
del ast["optional"]
# convert the literal node types to ESTree standard form
if ast["type"] in HERMES_LITERAL_NODE_TYPES:
if ast["type"] == "NullLiteral":
Expand All @@ -137,6 +152,9 @@ def process_hermes_ast(self, ast):
ast["regex"] = {"pattern": ast["pattern"], "flags": ast["flags"]}
del ast["pattern"]
del ast["flags"]
if ast["type"] == "BigIntLiteral":
ast["bigint"] = ast["bigint"][:-1]
ast["value"] = None
ast["type"] = "Literal"
return ast

Expand All @@ -162,6 +180,7 @@ def process_esprima_ast(self, ast):
if (
ast["type"] == "ClassProperty"
or ast["type"] == "ClassPrivateProperty"
or ast["type"] == "PropertyDefinition"
):
if "declare" not in ast:
ast["declare"] = False
Expand Down

0 comments on commit 3ff366e

Please sign in to comment.