Skip to content

Commit

Permalink
test: split computed enum member tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bradzacher committed Dec 19, 2019
1 parent e91a7fe commit 1676146
Show file tree
Hide file tree
Showing 7 changed files with 857 additions and 104 deletions.
295 changes: 290 additions & 5 deletions packages/parser/tests/lib/__snapshots__/typescript.ts.snap
Expand Up @@ -15814,13 +15814,13 @@ Object {
}
`;

exports[`typescript fixtures/basics/export-named-enum-computed.src 1`] = `
exports[`typescript fixtures/basics/export-named-enum-computed-number.src 1`] = `
Object {
"$id": 3,
"block": Object {
"range": Array [
0,
42,
29,
],
"type": "Program",
},
Expand All @@ -15830,7 +15830,7 @@ Object {
"block": Object {
"range": Array [
0,
42,
29,
],
"type": "Program",
},
Expand All @@ -15840,7 +15840,7 @@ Object {
"block": Object {
"range": Array [
7,
41,
28,
],
"type": "TSEnumDeclaration",
},
Expand Down Expand Up @@ -15892,7 +15892,7 @@ Object {
"node": Object {
"range": Array [
7,
41,
28,
],
"type": "TSEnumDeclaration",
},
Expand Down Expand Up @@ -15934,6 +15934,291 @@ Object {
}
`;

exports[`typescript fixtures/basics/export-named-enum-computed-string.src 1`] = `
Object {
"$id": 3,
"block": Object {
"range": Array [
0,
33,
],
"type": "Program",
},
"childScopes": Array [
Object {
"$id": 2,
"block": Object {
"range": Array [
0,
33,
],
"type": "Program",
},
"childScopes": Array [
Object {
"$id": 1,
"block": Object {
"range": Array [
7,
32,
],
"type": "TSEnumDeclaration",
},
"childScopes": Array [],
"functionExpressionScope": false,
"isStrict": true,
"references": Array [],
"throughReferences": Array [],
"type": "enum",
"upperScope": Object {
"$ref": 2,
},
"variableMap": Object {},
"variableScope": Object {
"$ref": 2,
},
"variables": Array [],
},
],
"functionExpressionScope": false,
"isStrict": true,
"references": Array [],
"throughReferences": Array [],
"type": "module",
"upperScope": Object {
"$ref": 3,
},
"variableMap": Object {
"Foo": Object {
"$ref": 0,
},
},
"variableScope": Object {
"$ref": 2,
},
"variables": Array [
Object {
"$id": 0,
"defs": Array [
Object {
"name": Object {
"name": "Foo",
"range": Array [
12,
15,
],
"type": "Identifier",
},
"node": Object {
"range": Array [
7,
32,
],
"type": "TSEnumDeclaration",
},
"parent": undefined,
"type": "EnumName",
},
],
"eslintUsed": undefined,
"identifiers": Array [
Object {
"name": "Foo",
"range": Array [
12,
15,
],
"type": "Identifier",
},
],
"name": "Foo",
"references": Array [],
"scope": Object {
"$ref": 2,
},
},
],
},
],
"functionExpressionScope": false,
"isStrict": false,
"references": Array [],
"throughReferences": Array [],
"type": "global",
"upperScope": null,
"variableMap": Object {},
"variableScope": Object {
"$ref": 3,
},
"variables": Array [],
}
`;

exports[`typescript fixtures/basics/export-named-enum-computed-var-ref.src 1`] = `
Object {
"$id": 4,
"block": Object {
"range": Array [
0,
29,
],
"type": "Program",
},
"childScopes": Array [
Object {
"$id": 3,
"block": Object {
"range": Array [
0,
29,
],
"type": "Program",
},
"childScopes": Array [
Object {
"$id": 2,
"block": Object {
"range": Array [
7,
28,
],
"type": "TSEnumDeclaration",
},
"childScopes": Array [],
"functionExpressionScope": false,
"isStrict": true,
"references": Array [],
"throughReferences": Array [],
"type": "enum",
"upperScope": Object {
"$ref": 3,
},
"variableMap": Object {
"x": Object {
"$ref": 1,
},
},
"variableScope": Object {
"$ref": 3,
},
"variables": Array [
Object {
"$id": 1,
"defs": Array [
Object {
"name": Object {
"name": "x",
"range": Array [
23,
24,
],
"type": "Identifier",
},
"node": Object {
"range": Array [
22,
25,
],
"type": "TSEnumMember",
},
"parent": undefined,
"type": "EnumMemberName",
},
],
"eslintUsed": undefined,
"identifiers": Array [
Object {
"name": "x",
"range": Array [
23,
24,
],
"type": "Identifier",
},
],
"name": "x",
"references": Array [],
"scope": Object {
"$ref": 2,
},
},
],
},
],
"functionExpressionScope": false,
"isStrict": true,
"references": Array [],
"throughReferences": Array [],
"type": "module",
"upperScope": Object {
"$ref": 4,
},
"variableMap": Object {
"Foo": Object {
"$ref": 0,
},
},
"variableScope": Object {
"$ref": 3,
},
"variables": Array [
Object {
"$id": 0,
"defs": Array [
Object {
"name": Object {
"name": "Foo",
"range": Array [
12,
15,
],
"type": "Identifier",
},
"node": Object {
"range": Array [
7,
28,
],
"type": "TSEnumDeclaration",
},
"parent": undefined,
"type": "EnumName",
},
],
"eslintUsed": undefined,
"identifiers": Array [
Object {
"name": "Foo",
"range": Array [
12,
15,
],
"type": "Identifier",
},
],
"name": "Foo",
"references": Array [],
"scope": Object {
"$ref": 3,
},
},
],
},
],
"functionExpressionScope": false,
"isStrict": false,
"references": Array [],
"throughReferences": Array [],
"type": "global",
"upperScope": null,
"variableMap": Object {},
"variableScope": Object {
"$ref": 4,
},
"variables": Array [],
}
`;

exports[`typescript fixtures/basics/export-type-alias-declaration.src 1`] = `
Object {
"$id": 1,
Expand Down
@@ -0,0 +1,3 @@
export enum Foo {
[1],
}
@@ -1,4 +1,3 @@
export enum Foo {
['baz'],
[1],
}
@@ -0,0 +1,3 @@
export enum Foo {
[x],
}
Expand Up @@ -616,6 +616,8 @@ tester.addFixturePatternConfig('typescript/basics', {
'class-with-readonly-property',
'object-with-escaped-properties',
'type-reference-comments',
// babel hard fails on computed string enum members, but TS doesn't
'export-named-enum-computed-string',
],
ignoreSourceType: [
/**
Expand Down
Expand Up @@ -1831,15 +1831,26 @@ exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" e

exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/export-named-enum.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;

exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/export-named-enum-computed.src 1`] = `
exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/export-named-enum-computed-number.src 1`] = `
Object {
"column": 4,
"index": 35,
"lineNumber": 3,
"index": 22,
"lineNumber": 2,
"message": "An enum member cannot have a numeric name.",
}
`;

exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/export-named-enum-computed-string.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;

exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/export-named-enum-computed-var-ref.src 1`] = `
Object {
"column": 4,
"index": 22,
"lineNumber": 2,
"message": "Computed property names are not allowed in enums.",
}
`;

exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/export-type-alias-declaration.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;

exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/export-type-class-declaration.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;
Expand Down

0 comments on commit 1676146

Please sign in to comment.