Skip to content

Commit

Permalink
tests: Add a test attempt for rust-lang/rust#57462.
Browse files Browse the repository at this point in the history
This unfortunately passes regardless right now because of the racer fallback.
And without the racer fallback we're not able to go to the definition of either
Foo or Foo::new.
  • Loading branch information
emilio committed Jan 9, 2019
1 parent ea7a0c3 commit 0b36c18
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1364,3 +1364,75 @@ fn cmd_lens_run() {

rls.shutdown(rls_timeout());
}

#[test]
fn test_def_static_method_call() {
let p = project("simple_workspace")
.file("Cargo.toml", &basic_bin_manifest("bar"))
.file(
"src/main.rs",
r#"
struct Foo {
}
impl Foo {
fn new() {
}
}
fn main() {
Foo::new();
}
"#,
)
.build();

let root_path = p.root();
let mut rls = p.spawn_rls();

rls.request(
0,
"initialize",
Some(json!({
"rootPath": root_path,
"capabilities": {}
})),
)
.unwrap();

let request_id = 1;

rls.request(
request_id,
"textDocument/definition",
Some(json!({
"position": {
"character": 20, // Foo
"line": 10
},
"textDocument": {
"uri": format!("file://{}/src/main.rs", root_path.display()),
"version": 1
}
})),
)
.unwrap();

let json = rls.wait_until_json_id(request_id, rls_timeout());
let result = json["result"].as_array().unwrap();
assert_eq!(
result[0]["range"],
json!({
"start": {
"line": 1,
"character": 23,
},
"end": {
"line": 1,
"character": 23,
}
})
);

rls.shutdown(rls_timeout());
}

0 comments on commit 0b36c18

Please sign in to comment.