mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[incrParse] Allow whitespaces to be reparsed in test
This greatly improves the ergonomics of writing tests and outweighs the ability to test which whitespaces get parsed since their parsing overhead should be minimal.
This commit is contained in:
@@ -10,9 +10,9 @@
|
||||
// RUN: %incparse-test %s --test-case MULTI_EDIT_SAME_LINE
|
||||
|
||||
func foo() {
|
||||
}<reparse REPLACE>
|
||||
}
|
||||
|
||||
_ = <<REPLACE<6|||7>>></reparse REPLACE>
|
||||
<reparse REPLACE>_ = <<REPLACE<6|||7>>></reparse REPLACE>
|
||||
_ = <<REPLACE_BY_LONGER<6|||"Hello World">>>
|
||||
_ = <<REPLACE_BY_SHORTER<"Hello again"|||"a">>>
|
||||
<<INSERT<|||foo()>>>
|
||||
|
||||
@@ -509,9 +509,19 @@ bool verifyReusedRegions(ByteBasedSourceRangeSet ExpectedReparseRegions,
|
||||
bool NoUnexpectedParse = true;
|
||||
|
||||
for (auto ReparseRegion : UnexpectedReparseRegions.Ranges) {
|
||||
NoUnexpectedParse = false;
|
||||
auto ReparseRange = ReparseRegion.toSourceRange(SourceMgr, BufferID);
|
||||
|
||||
// To improve the ergonomics when writing tests we do not want to complain
|
||||
// about reparsed whitespaces.
|
||||
auto RangeStr =
|
||||
CharSourceRange(SourceMgr, ReparseRange.Start, ReparseRange.End).str();
|
||||
llvm::Regex WhitespaceOnlyRegex("^\\s*$", llvm::Regex::Newline);
|
||||
if (WhitespaceOnlyRegex.match(RangeStr)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
NoUnexpectedParse = false;
|
||||
|
||||
llvm::errs() << "\nERROR: Unexpectedly reparsed following region:\n";
|
||||
ReparseRange.print(llvm::errs(), SourceMgr);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user