From d0cc0f5f11c3e0745578fb6c4b8fd342fafd3762 Mon Sep 17 00:00:00 2001 From: Pig Fang Date: Mon, 20 Jun 2022 22:55:57 +0800 Subject: [PATCH] test(es/parser): Add a test case for instantiation expr --- .../instantiation-expr/bin-op/input.ts | 1 + .../instantiation-expr/bin-op/input.ts.json | 118 +++++++++++++++++- 2 files changed, 118 insertions(+), 1 deletion(-) diff --git a/crates/swc_ecma_parser/tests/typescript/instantiation-expr/bin-op/input.ts b/crates/swc_ecma_parser/tests/typescript/instantiation-expr/bin-op/input.ts index 45c049da4c37..937386ae71bc 100644 --- a/crates/swc_ecma_parser/tests/typescript/instantiation-expr/bin-op/input.ts +++ b/crates/swc_ecma_parser/tests/typescript/instantiation-expr/bin-op/input.ts @@ -2,3 +2,4 @@ a>c; a + c; a - c; +const a = b < (c >= d ? e : f); diff --git a/crates/swc_ecma_parser/tests/typescript/instantiation-expr/bin-op/input.ts.json b/crates/swc_ecma_parser/tests/typescript/instantiation-expr/bin-op/input.ts.json index 49111491a6c8..cdafc9adc463 100644 --- a/crates/swc_ecma_parser/tests/typescript/instantiation-expr/bin-op/input.ts.json +++ b/crates/swc_ecma_parser/tests/typescript/instantiation-expr/bin-op/input.ts.json @@ -2,7 +2,7 @@ "type": "Script", "span": { "start": 1, - "end": 43, + "end": 75, "ctxt": 0 }, "body": [ @@ -284,6 +284,122 @@ } } } + }, + { + "type": "VariableDeclaration", + "span": { + "start": 44, + "end": 75, + "ctxt": 0 + }, + "kind": "const", + "declare": false, + "declarations": [ + { + "type": "VariableDeclarator", + "span": { + "start": 50, + "end": 74, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 50, + "end": 51, + "ctxt": 0 + }, + "value": "a", + "optional": false, + "typeAnnotation": null + }, + "init": { + "type": "BinaryExpression", + "span": { + "start": 54, + "end": 74, + "ctxt": 0 + }, + "operator": "<", + "left": { + "type": "Identifier", + "span": { + "start": 54, + "end": 55, + "ctxt": 0 + }, + "value": "b", + "optional": false + }, + "right": { + "type": "ParenthesisExpression", + "span": { + "start": 58, + "end": 74, + "ctxt": 0 + }, + "expression": { + "type": "ConditionalExpression", + "span": { + "start": 59, + "end": 73, + "ctxt": 0 + }, + "test": { + "type": "BinaryExpression", + "span": { + "start": 59, + "end": 65, + "ctxt": 0 + }, + "operator": ">=", + "left": { + "type": "Identifier", + "span": { + "start": 59, + "end": 60, + "ctxt": 0 + }, + "value": "c", + "optional": false + }, + "right": { + "type": "Identifier", + "span": { + "start": 64, + "end": 65, + "ctxt": 0 + }, + "value": "d", + "optional": false + } + }, + "consequent": { + "type": "Identifier", + "span": { + "start": 68, + "end": 69, + "ctxt": 0 + }, + "value": "e", + "optional": false + }, + "alternate": { + "type": "Identifier", + "span": { + "start": 72, + "end": 73, + "ctxt": 0 + }, + "value": "f", + "optional": false + } + } + } + }, + "definite": false + } + ] } ], "interpreter": null