Skip to content

Commit

Permalink
fix hoverExtended tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Khady committed Nov 4, 2022
1 parent 74d42f7 commit c8b9f89
Showing 1 changed file with 66 additions and 19 deletions.
85 changes: 66 additions & 19 deletions ocaml-lsp-server/test/e2e-new/hover_extended.ml
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,25 @@ let print_hover hover =
|> Yojson.Safe.pretty_to_string ~std:false
|> print_endline

let default_hover_params =
{ HoverParams.position = Position.create ~line:0 ~character:0
; textDocument = TextDocumentIdentifier.create ~uri
; workDoneToken = None
}

let hover client position =
Client.request
client
(TextDocumentHover { default_hover_params with position })
(TextDocumentHover
{ HoverParams.position
; textDocument = TextDocumentIdentifier.create ~uri
; workDoneToken = None
})

let print_hover_extended resp =
resp |> Yojson.Safe.pretty_to_string ~std:false |> print_endline

let hover_extended client _position verbosity =
let hover_extended client position verbosity =
let params =
let required =
[ ( "textDocument"
, TextDocumentIdentifier.yojson_of_t
(TextDocumentIdentifier.create ~uri) )
; ("position", Position.yojson_of_t (Position.create ~line:0 ~character:0))
; ("position", Position.yojson_of_t position)
]
in
let params =
Expand Down Expand Up @@ -160,7 +158,15 @@ let foo_value : foo = Some 1
Fiber.return ()
in
test source req;
[%expect {| null |}]
[%expect
{|
{
"contents": { "kind": "plaintext", "value": "foo" },
"range": {
"end": { "character": 13, "line": 3 },
"start": { "character": 4, "line": 3 }
}
} |}]

let%expect_test "explicit verbosity 0" =
let source =
Expand All @@ -177,7 +183,15 @@ let foo_value : foo = Some 1
Fiber.return ()
in
test source req;
[%expect {| null |}]
[%expect
{|
{
"contents": { "kind": "plaintext", "value": "foo" },
"range": {
"end": { "character": 13, "line": 3 },
"start": { "character": 4, "line": 3 }
}
} |}]

let%expect_test "explicit verbosity 1" =
let source =
Expand All @@ -194,8 +208,15 @@ let foo_value : foo = Some 1
Fiber.return ()
in
test source req;
[%expect {|
null |}]
[%expect
{|
{
"contents": { "kind": "plaintext", "value": "int option" },
"range": {
"end": { "character": 13, "line": 3 },
"start": { "character": 4, "line": 3 }
}
} |}]

let%expect_test "explicit verbosity 2" =
let source =
Expand All @@ -212,8 +233,15 @@ let foo_value : foo = Some 1
Fiber.return ()
in
test source req;
[%expect {|
null |}]
[%expect
{|
{
"contents": { "kind": "plaintext", "value": "int option" },
"range": {
"end": { "character": 13, "line": 3 },
"start": { "character": 4, "line": 3 }
}
} |}]

let%expect_test "implicity verbosity increases" =
let source =
Expand All @@ -234,7 +262,26 @@ let foo_value : foo = Some 1
Fiber.return ()
in
test source req;
[%expect {|
null
null
null |}]
[%expect
{|
{
"contents": { "kind": "plaintext", "value": "foo" },
"range": {
"end": { "character": 13, "line": 3 },
"start": { "character": 4, "line": 3 }
}
}
{
"contents": { "kind": "plaintext", "value": "int option" },
"range": {
"end": { "character": 13, "line": 3 },
"start": { "character": 4, "line": 3 }
}
}
{
"contents": { "kind": "plaintext", "value": "int option" },
"range": {
"end": { "character": 13, "line": 3 },
"start": { "character": 4, "line": 3 }
}
} |}]

0 comments on commit c8b9f89

Please sign in to comment.