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 13f94b0 commit fbeeed8
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 @@ -1430,6 +1430,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 @@ -1440,7 +1443,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 @@ -1456,19 +1459,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 @@ -1483,7 +1485,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 @@ -1498,18 +1500,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 fbeeed8

Please sign in to comment.