Skip to content

Commit 5436a94

Browse files
kinto0meta-codesync[bot]
authored andcommitted
add more tests for related method references
Summary: title Reviewed By: yangdanny97 Differential Revision: D85469824 fbshipit-source-id: df2863eaa66979e999d8ae659f49b4f3bb114db9
1 parent 0e0a725 commit 5436a94

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

pyrefly/lib/test/lsp/local_find_refs.rs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,65 @@ References:
325325
);
326326
}
327327

328+
// todo(kylei): reference on child method should find parent method
329+
#[test]
330+
fn parent_method() {
331+
let code = r#"
332+
class C:
333+
def f(self) -> str: ...
334+
335+
class Concrete(C):
336+
def f(self) -> str:
337+
# ^
338+
return "test"
339+
"#;
340+
let report = get_batched_lsp_operations_report(&[("main", code)], get_test_report);
341+
assert_eq!(
342+
r#"
343+
# main.py
344+
6 | def f(self) -> str:
345+
^
346+
References:
347+
6 | def f(self) -> str:
348+
^
349+
"#
350+
.trim(),
351+
report.trim(),
352+
);
353+
}
354+
355+
// todo(kylei): reference on child method should find parent + other child methods
356+
#[test]
357+
fn sibling_method() {
358+
let code = r#"
359+
class C:
360+
def f(self) -> str: ...
361+
362+
class Concrete(C):
363+
def f(self) -> str:
364+
# ^
365+
return "test"
366+
367+
class Concrete2(C):
368+
def f(self) -> str:
369+
return "test"
370+
371+
"#;
372+
let report = get_batched_lsp_operations_report(&[("main", code)], get_test_report);
373+
assert_eq!(
374+
r#"
375+
# main.py
376+
6 | def f(self) -> str:
377+
^
378+
References:
379+
6 | def f(self) -> str:
380+
^
381+
"#
382+
.trim(),
383+
report.trim(),
384+
);
385+
}
386+
328387
// todo(kylei): references on renames should find lhs of assignment
329388
#[test]
330389
fn reassigned_local() {

0 commit comments

Comments
 (0)