Skip to content

Commit

Permalink
fix failing tests because of merlin regression: ocaml/merlin#1540
Browse files Browse the repository at this point in the history
  • Loading branch information
ulugbekna committed Dec 9, 2022
1 parent d85fae4 commit 511504b
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 4 deletions.
6 changes: 4 additions & 2 deletions ocaml-lsp-server/test/e2e/__tests__/ocamllsp-hoverExtended.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,14 @@ describe("ocamllsp/hoverExtended", () => {
(** This function has a nice documentation *)
let id x = x
let () = id ()
`,
),
});

let result = await languageServer.sendRequest("ocamllsp/hoverExtended", {
textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"),
position: Types.Position.create(1, 4),
position: Types.Position.create(3, 9),
verbosity: 0,
});

Expand Down Expand Up @@ -196,13 +197,14 @@ describe("ocamllsp/hoverExtended", () => {
let div x y =
x / y
let f = div 4 2
`,
),
});

let result = await languageServer.sendRequest("ocamllsp/hoverExtended", {
textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"),
position: Types.Position.create(20, 4),
position: Types.Position.create(23, 10),
verbosity: 0,
});

Expand Down
50 changes: 48 additions & 2 deletions ocaml-lsp-server/test/e2e/__tests__/textDocument-hover.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ describe("textDocument/hover", () => {
});
});

it("returns type inferred under cursor with documentation", async () => {
// checks for regression https://github.com/ocaml/merlin/issues/1540
// FIXME: when we can again fetch documentation, update this test
it("returns type inferred under cursor with documentation in let-definition", async () => {
languageServer = await LanguageServer.startAndInitialize({
capabilities: {
textDocument: {
Expand Down Expand Up @@ -137,6 +139,49 @@ describe("textDocument/hover", () => {
position: Types.Position.create(1, 4),
});

expect(result).toMatchObject({
contents: {
kind: "markdown",
value: outdent`
\`\`\`ocaml
'a -> 'a
\`\`\`
`,
},
});
});

it("returns type inferred under cursor with documentation", async () => {
languageServer = await LanguageServer.startAndInitialize({
capabilities: {
textDocument: {
hover: {
dynamicRegistration: true,
contentFormat: ["markdown", "plaintext"],
},
moniker: {},
},
},
});
await languageServer.sendNotification("textDocument/didOpen", {
textDocument: Types.TextDocumentItem.create(
"file:///test.ml",
"ocaml",
0,
outdent`
(** This function has a nice documentation *)
let id x = x
let () = id ()
`,
),
});

let result = await languageServer.sendRequest("textDocument/hover", {
textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"),
position: Types.Position.create(3, 9),
});

expect(result).toMatchObject({
contents: {
kind: "markdown",
Expand Down Expand Up @@ -192,13 +237,14 @@ describe("textDocument/hover", () => {
let div x y =
x / y
let f = div 4 2
`,
),
});

let result = await languageServer.sendRequest("textDocument/hover", {
textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"),
position: Types.Position.create(20, 4),
position: Types.Position.create(23, 9),
});

expect(result).toMatchObject({
Expand Down

0 comments on commit 511504b

Please sign in to comment.