Skip to content

Commit

Permalink
[flow][match] Tests for find-references on match pattern bindings
Browse files Browse the repository at this point in the history
Summary:
Tests for find-references on match pattern bindings.

Changelog: [internal]

Reviewed By: SamChou19815

Differential Revision: D67842016

fbshipit-source-id: 174e89840627d3134e3f8ef2d8447d88ca39d130
  • Loading branch information
gkz authored and facebook-github-bot committed Jan 7, 2025
1 parent d4a2cb2 commit c515999
Show file tree
Hide file tree
Showing 9 changed files with 215 additions and 0 deletions.
12 changes: 12 additions & 0 deletions newtests/lsp/findReferences/__fixtures__/match.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// @flow

declare const x: mixed;

const e = match (x) {
[const a]: a,
{foo: const a}: a,
{const a}: a,
1 as const a: a,
2 as a: a,
const a: a,
};
31 changes: 31 additions & 0 deletions newtests/lsp/findReferences/__snapshots__/match-as-const.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"method": "textDocument/references",
"result": [
{
"uri": "<PLACEHOLDER_PROJECT_URL>/__fixtures__/match.js",
"range": {
"start": {
"line": 8,
"character": 13
},
"end": {
"line": 8,
"character": 14
}
}
},
{
"uri": "<PLACEHOLDER_PROJECT_URL>/__fixtures__/match.js",
"range": {
"start": {
"line": 8,
"character": 16
},
"end": {
"line": 8,
"character": 17
}
}
}
]
}
31 changes: 31 additions & 0 deletions newtests/lsp/findReferences/__snapshots__/match-as.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"method": "textDocument/references",
"result": [
{
"uri": "<PLACEHOLDER_PROJECT_URL>/__fixtures__/match.js",
"range": {
"start": {
"line": 9,
"character": 7
},
"end": {
"line": 9,
"character": 8
}
}
},
{
"uri": "<PLACEHOLDER_PROJECT_URL>/__fixtures__/match.js",
"range": {
"start": {
"line": 9,
"character": 10
},
"end": {
"line": 9,
"character": 11
}
}
}
]
}
31 changes: 31 additions & 0 deletions newtests/lsp/findReferences/__snapshots__/match-binding-top.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"method": "textDocument/references",
"result": [
{
"uri": "<PLACEHOLDER_PROJECT_URL>/__fixtures__/match.js",
"range": {
"start": {
"line": 10,
"character": 8
},
"end": {
"line": 10,
"character": 9
}
}
},
{
"uri": "<PLACEHOLDER_PROJECT_URL>/__fixtures__/match.js",
"range": {
"start": {
"line": 10,
"character": 11
},
"end": {
"line": 10,
"character": 12
}
}
}
]
}
31 changes: 31 additions & 0 deletions newtests/lsp/findReferences/__snapshots__/match-obj-long.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"method": "textDocument/references",
"result": [
{
"uri": "<PLACEHOLDER_PROJECT_URL>/__fixtures__/match.js",
"range": {
"start": {
"line": 6,
"character": 14
},
"end": {
"line": 6,
"character": 15
}
}
},
{
"uri": "<PLACEHOLDER_PROJECT_URL>/__fixtures__/match.js",
"range": {
"start": {
"line": 6,
"character": 18
},
"end": {
"line": 6,
"character": 19
}
}
}
]
}
31 changes: 31 additions & 0 deletions newtests/lsp/findReferences/__snapshots__/match-obj-shorthand.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"method": "textDocument/references",
"result": [
{
"uri": "<PLACEHOLDER_PROJECT_URL>/__fixtures__/match.js",
"range": {
"start": {
"line": 7,
"character": 9
},
"end": {
"line": 7,
"character": 10
}
}
},
{
"uri": "<PLACEHOLDER_PROJECT_URL>/__fixtures__/match.js",
"range": {
"start": {
"line": 7,
"character": 13
},
"end": {
"line": 7,
"character": 14
}
}
}
]
}
31 changes: 31 additions & 0 deletions newtests/lsp/findReferences/__snapshots__/match-tuple.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"method": "textDocument/references",
"result": [
{
"uri": "<PLACEHOLDER_PROJECT_URL>/__fixtures__/match.js",
"range": {
"start": {
"line": 5,
"character": 9
},
"end": {
"line": 5,
"character": 10
}
}
},
{
"uri": "<PLACEHOLDER_PROJECT_URL>/__fixtures__/match.js",
"range": {
"start": {
"line": 5,
"character": 13
},
"end": {
"line": 5,
"character": 14
}
}
}
]
}
2 changes: 2 additions & 0 deletions newtests/lsp/findReferences/_flowconfig_match
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[options]
experimental.pattern_matching_expressions=true
15 changes: 15 additions & 0 deletions newtests/lsp/findReferences/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ module.exports = (suite(
lspStartAndConnect(),
snapshot('locals.js', 29, 16, 'jsx_props.json'),
]),
test('JSX Props', [
addFiles(...fixtures),
lspStartAndConnect(),
snapshot('locals.js', 29, 16, 'jsx_props.json'),
]),
test('Private Names', [
addFiles(...fixtures),
lspStartAndConnect(),
Expand All @@ -79,6 +84,16 @@ module.exports = (suite(
snapshot('private-name.js', 20, 17, 'private-name-3.json'),
snapshot('private-name.js', 23, 12, 'private-name-4.json'),
]),
test('Match', [
addFiles(...fixtures),
lspStartAndConnect(),
snapshot('match.js', 5, 10, 'match-tuple.json'),
snapshot('match.js', 6, 15, 'match-obj-long.json'),
snapshot('match.js', 7, 10, 'match-obj-shorthand.json'),
snapshot('match.js', 8, 14, 'match-as-const.json'),
snapshot('match.js', 9, 8, 'match-as.json'),
snapshot('match.js', 10, 9, 'match-binding-top.json'),
]).flowConfig('_flowconfig_match'),
];
},
): SuiteType);

0 comments on commit c515999

Please sign in to comment.