-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more tests for textDocument/references
commit-id:f830ed8f
- Loading branch information
Showing
9 changed files
with
567 additions
and
0 deletions.
There are no files selected for viewing
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,48 @@ | ||
//! > Test references of enum variants. | ||
|
||
//! > test_runner_name | ||
test_references(include_declaration: false) | ||
|
||
//! > cairo_code | ||
enum Foo { | ||
Bar, | ||
Baz, | ||
} | ||
|
||
fn main() { | ||
let foo = Foo::Ba<caret>r; | ||
match foo { | ||
Foo::Bar => {} // FIXME(#164): This should work. | ||
_ => {} | ||
} | ||
} | ||
|
||
//! > References #0 | ||
let foo = Foo::Ba<caret>r; | ||
--- | ||
|
||
//! > ========================================================================== | ||
|
||
//! > Test references of enum variants including declaration. | ||
|
||
//! > test_runner_name | ||
test_references(include_declaration: true) | ||
|
||
//! > cairo_code | ||
enum Foo { | ||
Bar, | ||
Baz, | ||
} | ||
|
||
fn main() { | ||
let foo = Foo::Ba<caret>r; | ||
match foo { | ||
Foo::Bar => {} // FIXME(#164): This should work. | ||
_ => {} | ||
} | ||
} | ||
|
||
//! > References #0 | ||
let foo = Foo::Ba<caret>r; | ||
--- | ||
<sel>Bar</sel>, |
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,86 @@ | ||
//! > Test find references of an enum. | ||
|
||
//! > test_runner_name | ||
test_references(include_declaration: true) | ||
|
||
//! > cairo_code | ||
enum Fo<caret>o { | ||
Bar, | ||
Baz, | ||
} | ||
|
||
fn main() { | ||
let foo = Fo<caret>o::Bar; | ||
let foobar: Fo<caret>o = foo; | ||
} | ||
|
||
fn calc(foo: Fo<caret>o) {} | ||
|
||
mod rectangle { | ||
use super::Fo<caret>o; | ||
} | ||
|
||
//! > References #0 | ||
enum Fo<caret>o { | ||
--- | ||
<sel>enum Foo { | ||
Bar, | ||
Baz, | ||
}</sel> | ||
enum <sel>Foo</sel> { | ||
let foo = <sel>Foo</sel>::Bar; | ||
let foobar: <sel>Foo</sel> = foo; | ||
fn calc(foo: <sel>Foo</sel>) {} | ||
use super::<sel>Foo</sel>; | ||
|
||
//! > References #1 | ||
let foo = Fo<caret>o::Bar; | ||
--- | ||
<sel>enum Foo { | ||
Bar, | ||
Baz, | ||
}</sel> | ||
enum <sel>Foo</sel> { | ||
let foo = <sel>Foo</sel>::Bar; | ||
let foobar: <sel>Foo</sel> = foo; | ||
fn calc(foo: <sel>Foo</sel>) {} | ||
use super::<sel>Foo</sel>; | ||
|
||
//! > References #2 | ||
let foobar: Fo<caret>o = foo; | ||
--- | ||
<sel>enum Foo { | ||
Bar, | ||
Baz, | ||
}</sel> | ||
enum <sel>Foo</sel> { | ||
let foo = <sel>Foo</sel>::Bar; | ||
let foobar: <sel>Foo</sel> = foo; | ||
fn calc(foo: <sel>Foo</sel>) {} | ||
use super::<sel>Foo</sel>; | ||
|
||
//! > References #3 | ||
fn calc(foo: Fo<caret>o) {} | ||
--- | ||
<sel>enum Foo { | ||
Bar, | ||
Baz, | ||
}</sel> | ||
enum <sel>Foo</sel> { | ||
let foo = <sel>Foo</sel>::Bar; | ||
let foobar: <sel>Foo</sel> = foo; | ||
fn calc(foo: <sel>Foo</sel>) {} | ||
use super::<sel>Foo</sel>; | ||
|
||
//! > References #4 | ||
use super::Fo<caret>o; | ||
--- | ||
<sel>enum Foo { | ||
Bar, | ||
Baz, | ||
}</sel> | ||
enum <sel>Foo</sel> { | ||
let foo = <sel>Foo</sel>::Bar; | ||
let foobar: <sel>Foo</sel> = foo; | ||
fn calc(foo: <sel>Foo</sel>) {} | ||
use super::<sel>Foo</sel>; |
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,67 @@ | ||
//! > Test references of methods. | ||
|
||
//! > test_runner_name | ||
test_references(include_declaration: true) | ||
|
||
//! > cairo_code | ||
#[derive(Drop)] | ||
struct Foo {} | ||
|
||
trait FooTrait { | ||
fn are<caret>a(self: @Foo) -> u64; | ||
} | ||
|
||
impl FooImpl of FooTrait { | ||
// FIXME(#170): Does not work as expected. | ||
fn are<caret>a(self: @Foo) -> u64 { 0 } | ||
} | ||
|
||
#[derive(Drop)] | ||
struct Bar {} | ||
|
||
trait BarTrait { | ||
fn area(self: @Bar) -> u64; | ||
} | ||
|
||
impl BarImpl of BarTrait { | ||
fn area(self: @Bar) -> u64 { 0 } | ||
} | ||
|
||
fn main() { | ||
let foo = Foo {}; | ||
let x = foo.are<caret>a(); | ||
let y = FooTrait::are<caret>a(foo); | ||
} | ||
|
||
//! > References #0 | ||
fn are<caret>a(self: @Foo) -> u64; | ||
--- | ||
<sel>fn area(self: @Foo) -> u64;</sel> | ||
fn <sel>area</sel>(self: @Foo) -> u64; | ||
let x = foo.<sel>area</sel>(); | ||
let y = FooTrait::<sel>area</sel>(foo); | ||
|
||
//! > References #1 | ||
fn are<caret>a(self: @Foo) -> u64 { 0 } | ||
--- | ||
<sel>impl FooImpl of FooTrait { | ||
// FIXME(#170): Does not work as expected. | ||
fn area(self: @Foo) -> u64 { 0 } | ||
}</sel> | ||
impl <sel>FooImpl</sel> of FooTrait { | ||
|
||
//! > References #2 | ||
let x = foo.are<caret>a(); | ||
--- | ||
<sel>fn area(self: @Foo) -> u64;</sel> | ||
fn <sel>area</sel>(self: @Foo) -> u64; | ||
let x = foo.<sel>area</sel>(); | ||
let y = FooTrait::<sel>area</sel>(foo); | ||
|
||
//! > References #3 | ||
let y = FooTrait::are<caret>a(foo); | ||
--- | ||
<sel>fn area(self: @Foo) -> u64;</sel> | ||
fn <sel>area</sel>(self: @Foo) -> u64; | ||
let x = foo.<sel>area</sel>(); | ||
let y = FooTrait::<sel>area</sel>(foo); |
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,63 @@ | ||
//! > Test references of struct members. | ||
|
||
//! > test_runner_name | ||
test_references(include_declaration: false) | ||
|
||
//! > cairo_code | ||
#[derive(Drop)] | ||
struct Rectangle { | ||
// FIXME(#129): The results for this are very off. | ||
wid<caret>th: u64, | ||
height: u64, | ||
} | ||
|
||
fn main() { | ||
let rectangle = Rectangle { wid<caret>th: 0, height: 0 }; | ||
} | ||
|
||
fn calculate_area(rectangle: Rectangle) -> u64 { | ||
rectangle.wi<caret>dth * rectangle.height | ||
} | ||
|
||
//! > References #0 | ||
wid<caret>th: u64, | ||
--- | ||
struct <sel>Rectangle</sel> { | ||
let rectangle = <sel>Rectangle</sel> { width: 0, height: 0 }; | ||
fn calculate_area(rectangle: <sel>Rectangle</sel>) -> u64 { | ||
|
||
//! > References #1 | ||
let rectangle = Rectangle { wid<caret>th: 0, height: 0 }; | ||
--- | ||
let rectangle = Rectangle { <sel>width</sel>: 0, height: 0 }; | ||
rectangle.<sel>width</sel> * rectangle.height | ||
|
||
//! > References #2 | ||
rectangle.wi<caret>dth * rectangle.height | ||
--- | ||
let rectangle = Rectangle { <sel>width</sel>: 0, height: 0 }; | ||
rectangle.<sel>width</sel> * rectangle.height | ||
|
||
//! > ========================================================================== | ||
|
||
//! > Test references of struct members including declaration. | ||
|
||
//! > test_runner_name | ||
test_references(include_declaration: true) | ||
|
||
//! > cairo_code | ||
#[derive(Drop)] | ||
struct Rectangle { | ||
width: u64, | ||
height: u64, | ||
} | ||
|
||
fn calculate_area(rectangle: Rectangle) -> u64 { | ||
rectangle.wi<caret>dth * rectangle.height | ||
} | ||
|
||
//! > References #0 | ||
rectangle.wi<caret>dth * rectangle.height | ||
--- | ||
<sel>width: u64</sel>, | ||
rectangle.<sel>width</sel> * rectangle.height |
Oops, something went wrong.