-
-
Notifications
You must be signed in to change notification settings - Fork 477
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(semantic): copy tests from typescript-eslint’s scope-manager (#…
…3990) close: #2947 These fixtures were copied from https://github.com/typescript-eslint/typescript-eslint/tree/a5b652da1ebb09ecbca8f4b032bf05ebc0e03dc9/packages/scope-manager/tests/fixtures. We used them to test out semantic `ScopeTree` and `SymbolTable`
- Loading branch information
Showing
573 changed files
with
15,655 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
These fixtures were copied from https://github.com/typescript-eslint/typescript-eslint/tree/a5b652da1ebb09ecbca8f4b032bf05ebc0e03dc9/packages/scope-manager/tests/fixtures. We used them to test out semantic [ScopeTree](../../src/scope.rs) and [SymbolTable](../../src/symbol.rs) |
36 changes: 36 additions & 0 deletions
36
crates/oxc_semantic/tests/fixtures/typescript-eslint/block/inherited-scope.snap
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,36 @@ | ||
--- | ||
source: crates/oxc_semantic/tests/main.rs | ||
input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/block/inherited-scope.ts | ||
--- | ||
[ | ||
{ | ||
"children": [ | ||
{ | ||
"children": [], | ||
"flag": "ScopeFlags(StrictMode)", | ||
"id": 1, | ||
"node": "BlockStatement", | ||
"symbols": [] | ||
} | ||
], | ||
"flag": "ScopeFlags(StrictMode | Top)", | ||
"id": 0, | ||
"node": "Program", | ||
"symbols": [ | ||
{ | ||
"flag": "SymbolFlags(BlockScopedVariable | ConstVariable)", | ||
"id": 0, | ||
"name": "a", | ||
"node": "VariableDeclarator", | ||
"references": [ | ||
{ | ||
"flag": "ReferenceFlag(Read)", | ||
"id": 0, | ||
"name": "a", | ||
"node_id": 7 | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] |
5 changes: 5 additions & 0 deletions
5
crates/oxc_semantic/tests/fixtures/typescript-eslint/block/inherited-scope.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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const a = 1; | ||
|
||
{ | ||
a; | ||
} |
43 changes: 43 additions & 0 deletions
43
crates/oxc_semantic/tests/fixtures/typescript-eslint/block/scope.snap
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,43 @@ | ||
--- | ||
source: crates/oxc_semantic/tests/main.rs | ||
input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/block/scope.ts | ||
--- | ||
[ | ||
{ | ||
"children": [ | ||
{ | ||
"children": [], | ||
"flag": "ScopeFlags(StrictMode)", | ||
"id": 1, | ||
"node": "BlockStatement", | ||
"symbols": [ | ||
{ | ||
"flag": "SymbolFlags(BlockScopedVariable)", | ||
"id": 0, | ||
"name": "i", | ||
"node": "VariableDeclarator", | ||
"references": [ | ||
{ | ||
"flag": "ReferenceFlag(Read)", | ||
"id": 0, | ||
"name": "i", | ||
"node_id": 11 | ||
} | ||
] | ||
}, | ||
{ | ||
"flag": "SymbolFlags(BlockScopedVariable)", | ||
"id": 1, | ||
"name": "j", | ||
"node": "VariableDeclarator", | ||
"references": [] | ||
} | ||
] | ||
} | ||
], | ||
"flag": "ScopeFlags(StrictMode | Top)", | ||
"id": 0, | ||
"node": "Program", | ||
"symbols": [] | ||
} | ||
] |
7 changes: 7 additions & 0 deletions
7
crates/oxc_semantic/tests/fixtures/typescript-eslint/block/scope.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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
let i = 20; | ||
let j = 1; | ||
i; | ||
} | ||
|
||
j; |
62 changes: 62 additions & 0 deletions
62
crates/oxc_semantic/tests/fixtures/typescript-eslint/call-expression/call-expression.snap
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,62 @@ | ||
--- | ||
source: crates/oxc_semantic/tests/main.rs | ||
input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/call-expression/call-expression.ts | ||
--- | ||
[ | ||
{ | ||
"children": [ | ||
{ | ||
"children": [], | ||
"flag": "ScopeFlags(StrictMode | Function | Arrow)", | ||
"id": 1, | ||
"node": "ArrowFunctionExpression", | ||
"symbols": [] | ||
} | ||
], | ||
"flag": "ScopeFlags(StrictMode | Top)", | ||
"id": 0, | ||
"node": "Program", | ||
"symbols": [ | ||
{ | ||
"flag": "SymbolFlags(BlockScopedVariable | ConstVariable)", | ||
"id": 0, | ||
"name": "foo", | ||
"node": "VariableDeclarator", | ||
"references": [ | ||
{ | ||
"flag": "ReferenceFlag(Read)", | ||
"id": 0, | ||
"name": "foo", | ||
"node_id": 15 | ||
}, | ||
{ | ||
"flag": "ReferenceFlag(Read)", | ||
"id": 1, | ||
"name": "foo", | ||
"node_id": 21 | ||
} | ||
] | ||
}, | ||
{ | ||
"flag": "SymbolFlags(BlockScopedVariable | ConstVariable)", | ||
"id": 1, | ||
"name": "a", | ||
"node": "VariableDeclarator", | ||
"references": [ | ||
{ | ||
"flag": "ReferenceFlag(Read)", | ||
"id": 0, | ||
"name": "a", | ||
"node_id": 14 | ||
}, | ||
{ | ||
"flag": "ReferenceFlag(Read)", | ||
"id": 1, | ||
"name": "a", | ||
"node_id": 20 | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] |
5 changes: 5 additions & 0 deletions
5
crates/oxc_semantic/tests/fixtures/typescript-eslint/call-expression/call-expression.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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const foo = () => {}; | ||
const a = 1; | ||
|
||
foo(a); | ||
foo?.(a); |
36 changes: 36 additions & 0 deletions
36
crates/oxc_semantic/tests/fixtures/typescript-eslint/call-expression/type-parameters1.snap
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,36 @@ | ||
--- | ||
source: crates/oxc_semantic/tests/main.rs | ||
input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/call-expression/type-parameters1.ts | ||
--- | ||
[ | ||
{ | ||
"children": [ | ||
{ | ||
"children": [], | ||
"flag": "ScopeFlags(StrictMode)", | ||
"id": 1, | ||
"node": "TSTypeAliasDeclaration", | ||
"symbols": [] | ||
} | ||
], | ||
"flag": "ScopeFlags(StrictMode | Top)", | ||
"id": 0, | ||
"node": "Program", | ||
"symbols": [ | ||
{ | ||
"flag": "SymbolFlags(TypeAlias)", | ||
"id": 0, | ||
"name": "T", | ||
"node": "TSTypeAliasDeclaration", | ||
"references": [ | ||
{ | ||
"flag": "ReferenceFlag(Type)", | ||
"id": 0, | ||
"name": "T", | ||
"node_id": 11 | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] |
2 changes: 2 additions & 0 deletions
2
crates/oxc_semantic/tests/fixtures/typescript-eslint/call-expression/type-parameters1.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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
type T = 1; | ||
foo<T>(); |
21 changes: 21 additions & 0 deletions
21
crates/oxc_semantic/tests/fixtures/typescript-eslint/call-expression/type-parameters2.snap
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,21 @@ | ||
--- | ||
source: crates/oxc_semantic/tests/main.rs | ||
input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/call-expression/type-parameters2.ts | ||
--- | ||
[ | ||
{ | ||
"children": [], | ||
"flag": "ScopeFlags(StrictMode | Top)", | ||
"id": 0, | ||
"node": "Program", | ||
"symbols": [ | ||
{ | ||
"flag": "SymbolFlags(BlockScopedVariable | ConstVariable)", | ||
"id": 0, | ||
"name": "T", | ||
"node": "VariableDeclarator", | ||
"references": [] | ||
} | ||
] | ||
} | ||
] |
2 changes: 2 additions & 0 deletions
2
crates/oxc_semantic/tests/fixtures/typescript-eslint/call-expression/type-parameters2.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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
const T = 1; | ||
foo<T>(); // should not resolve to value |
67 changes: 67 additions & 0 deletions
67
crates/oxc_semantic/tests/fixtures/typescript-eslint/catch/inherited-scope.snap
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,67 @@ | ||
--- | ||
source: crates/oxc_semantic/tests/main.rs | ||
input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/catch/inherited-scope.ts | ||
--- | ||
[ | ||
{ | ||
"children": [ | ||
{ | ||
"children": [], | ||
"flag": "ScopeFlags(StrictMode)", | ||
"id": 1, | ||
"node": "BlockStatement", | ||
"symbols": [] | ||
}, | ||
{ | ||
"children": [ | ||
{ | ||
"children": [], | ||
"flag": "ScopeFlags(StrictMode)", | ||
"id": 3, | ||
"node": "BlockStatement", | ||
"symbols": [ | ||
{ | ||
"flag": "SymbolFlags(FunctionScopedVariable | CatchVariable)", | ||
"id": 1, | ||
"name": "e", | ||
"node": "CatchParameter", | ||
"references": [] | ||
} | ||
] | ||
} | ||
], | ||
"flag": "ScopeFlags(StrictMode | CatchClause)", | ||
"id": 2, | ||
"node": "CatchClause", | ||
"symbols": [ | ||
{ | ||
"flag": "SymbolFlags(FunctionScopedVariable | CatchVariable)", | ||
"id": 1, | ||
"name": "e", | ||
"node": "CatchParameter", | ||
"references": [] | ||
} | ||
] | ||
} | ||
], | ||
"flag": "ScopeFlags(StrictMode | Top)", | ||
"id": 0, | ||
"node": "Program", | ||
"symbols": [ | ||
{ | ||
"flag": "SymbolFlags(BlockScopedVariable | ConstVariable)", | ||
"id": 0, | ||
"name": "a", | ||
"node": "VariableDeclarator", | ||
"references": [ | ||
{ | ||
"flag": "ReferenceFlag(Read)", | ||
"id": 0, | ||
"name": "a", | ||
"node_id": 12 | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] |
5 changes: 5 additions & 0 deletions
5
crates/oxc_semantic/tests/fixtures/typescript-eslint/catch/inherited-scope.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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const a = 1; | ||
try { | ||
} catch (e) { | ||
a; | ||
} |
Oops, something went wrong.