Skip to content

Commit

Permalink
verilog: tools: ls: verilog-language-server: test: Marked places wher…
Browse files Browse the repository at this point in the history
…e hover is applied, added using dedicated class

Signed-off-by: Grzegorz Latosinski <[email protected]>
  • Loading branch information
glatosinski committed May 18, 2023
1 parent 0265a8b commit 18c4071
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions verilog/tools/ls/verilog-language-server_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1449,6 +1449,9 @@ TEST_F(VerilogLanguageServerSymbolTableTest, CheckReferenceUnknownSymbol) {
ASSERT_EQ(response_b["result"].size(), 0);
}

// Checks if the hover appears on port symbols
// In this test the hover for "sum" symbol in assign
// is checked
TEST_F(VerilogLanguageServerSymbolTableTest, HoverOverSymbol) {
absl::string_view filelist_content = "mod.v\n";
static constexpr absl::string_view //
Expand All @@ -1459,7 +1462,7 @@ TEST_F(VerilogLanguageServerSymbolTableTest, HoverOverSymbol) {
input reg [31:0] b,
output reg [31:0] sum);
always @(posedge clk) begin : addition
assign sum = a + b;
assign sum = a + b; // hover over sum
end
endmodule
)");
Expand All @@ -1475,19 +1478,18 @@ endmodule

GetResponse();

std::string hover_request =
HoverRequest("file://" + module.filename(), 2, 6, 12);
std::string hover_request = HoverRequest("file://" + module.filename(), 2,
/* line */ 6, /* column */ 12);

ASSERT_OK(SendRequest(hover_request));
json response = json::parse(GetResponse());
verible::lsp::Hover hover = response["result"];

ASSERT_EQ(response["id"], 2);
ASSERT_EQ(response["result"].size(), 1);
ASSERT_EQ(response["result"]["contents"]["kind"], "markdown");
ASSERT_TRUE(absl::StrContains(response["result"]["contents"]["value"],
ASSERT_EQ(hover.contents.kind, "markdown");
ASSERT_TRUE(absl::StrContains(hover.contents.value,
"data/net/var/instance sum"));
ASSERT_TRUE(
absl::StrContains(response["result"]["contents"]["value"], "reg [31:0]"));
absl::StrContains(hover.contents.value, "reg [31:0]"));
}

// Checks if the hover appears on "end" token when block name is available
Expand All @@ -1502,7 +1504,7 @@ TEST_F(VerilogLanguageServerSymbolTableTest, HoverOverEnd) {
output reg [31:0] sum);
always @(posedge clk) begin : addition
assign sum = a + b;
end
end // hover over end
endmodule
)");

Expand All @@ -1517,18 +1519,17 @@ endmodule

GetResponse();

std::string hover_request =
HoverRequest("file://" + module.filename(), 2, 7, 3);
std::string hover_request = HoverRequest("file://" + module.filename(), 2,
/* line */ 7, /* column */ 3);

ASSERT_OK(SendRequest(hover_request));
json response = json::parse(GetResponse());
verible::lsp::Hover hover = response["result"];

ASSERT_EQ(response["id"], 2);
ASSERT_EQ(response["result"].size(), 1);
ASSERT_EQ(response["result"]["contents"]["kind"], "markdown");
ASSERT_TRUE(absl::StrContains(response["result"]["contents"]["value"],
ASSERT_EQ(hover.contents.kind, "markdown");
ASSERT_TRUE(absl::StrContains(hover.contents.value,
"End of block"));
ASSERT_TRUE(absl::StrContains(response["result"]["contents"]["value"],
ASSERT_TRUE(absl::StrContains(hover.contents.value,
"Name: addition"));
}

Expand Down

0 comments on commit 18c4071

Please sign in to comment.