mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-27 06:50:09 +01:00
Start handling variable declarations (#571)
TODOs in the test for known issues. I may switch the approach to getting the variable type (on examination, this isn't working quite as well as I'd thought) but for now I think it's okay. I had an earlier approach though that may work better overall -- I'd been thinking this would work better, but as you can see in the null check for type information, I think I missed a key point. Anyways, what'd really been vexing me was `int i, j` which I think I handle passably well now. There's obviously room for improvement, but given I've been going at this for a couple days now, I thought it best to checkpoint where I was. This also includes some related framework changes to fix bumps I was running into. Overall the tool should operate a bit more smoothly with these changes. There are still issues with overlapping replacements, but I think it's primarily with range-based for loops which I just need to take some time to fix.
This commit is contained in:
@@ -24,12 +24,16 @@ void MatcherTestBase::ExpectReplacement(llvm::StringRef before,
|
||||
ct::FileContentMappings()));
|
||||
EXPECT_THAT(replacements, testing::ElementsAre(testing::Key(Filename)));
|
||||
auto actual = ct::applyAllReplacements(before, replacements[Filename]);
|
||||
// Split lines to get gmock to get an easier-to-read error.
|
||||
llvm::SmallVector<llvm::StringRef, 0> actual_lines;
|
||||
llvm::SplitString(*actual, actual_lines, "\n");
|
||||
llvm::SmallVector<llvm::StringRef, 0> after_lines;
|
||||
llvm::SplitString(after, after_lines, "\n");
|
||||
EXPECT_THAT(actual_lines, testing::ContainerEq(after_lines));
|
||||
if (after.find('\n') == std::string::npos) {
|
||||
EXPECT_THAT(*actual, testing::Eq(after.str()));
|
||||
} else {
|
||||
// Split lines to get gmock to get an easier-to-read error.
|
||||
llvm::SmallVector<llvm::StringRef, 0> actual_lines;
|
||||
llvm::SplitString(*actual, actual_lines, "\n");
|
||||
llvm::SmallVector<llvm::StringRef, 0> after_lines;
|
||||
llvm::SplitString(after, after_lines, "\n");
|
||||
EXPECT_THAT(actual_lines, testing::ContainerEq(after_lines));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Carbon
|
||||
|
||||
Reference in New Issue
Block a user