Skip to content

Commit

Permalink
[DSLX:fmt] Add regression test for over-long let statement.
Browse files Browse the repository at this point in the history
Towards google#1193

PiperOrigin-RevId: 583205607
  • Loading branch information
cdleary authored and copybara-github committed Nov 17, 2023
1 parent d324bfe commit f71d691
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions xls/dslx/fmt/ast_fmt_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1811,5 +1811,22 @@ fn f() {
EXPECT_EQ(got, kProgram);
}

// See github issue https://github.com/google/xls/issues/1193
TEST(ModuleFmtTest, LongLetLeader) {
const std::string_view kProgram = R"(import std
fn foo(some_value_that_is_pretty_long: u32, some_other_value_that_is_also_not_too_short: u32) {
type SomeTypeNameThatIsNotTooShort = s64;
let very_somewhat_long_variable_name: SomeTypeNameThatIsNotTooShort = std::to_signed(
some_value_that_is_pretty_long ++ some_other_value_that_is_also_not_too_short);
}
)";
std::vector<CommentData> comments;
XLS_ASSERT_OK_AND_ASSIGN(std::unique_ptr<Module> m,
ParseModule(kProgram, "fake.x", "fake", &comments));
std::string got = AutoFmt(*m, Comments::Create(comments));
EXPECT_EQ(got, kProgram);
}

} // namespace
} // namespace xls::dslx

0 comments on commit f71d691

Please sign in to comment.