Address comments around verbosity of tests.
Depends on D135859
Differential D137252
[include-cleaner] Testing helpers for ast walking kadircet on Nov 2 2022, 6:43 AM. Authored by
Diff Detail
Event TimelineComment Actions Just share my experience when reading the code, overall I have a feeling that we're regressing the code readability of the tests (left some comments on regressing samples):
That's being said, making the tests less verbose is good, but we seem to trade too much code readability for that. I'm fine with the original annotation version even though the annotations are somewhat noisy, another alternative -- if we use abbreviations like ($E, $I, $A) in tests, would it be better?
Comment Actions I see your point but this is not really a regression, right? that's the way the tests were written in the previous version as well. i am not sure how we can make this more explicit without introducing a bunch of boilerplate into each test case.
That is one of the points I disliked the most as well, maybe we should keep the old test syntax for these cases (with abbreviations), i.e. rather than putting the types at the end, we'll put them into the annotations. WDYT?
These macros are not for single references, but rather for single reference types. e.g. if all the references are of same kind.
Comment Actions In the previous version, we can easily distinguish the TargetCode and ReferenceCode by looking at annotation $name in the code, while in the current version, we have to memorize the function argument order. One alternative will be to merge TargetCode and ReferenceCode together: int ^x; // using ^ as a reference point to the target symbol int y = [[]]x; // using [[]]] as a ref point to the reference.
It can work, probably it is ok, it looks like -- we keep the original annotation approach (with shorter names), and provide some syntax sugar for common cases. (though I personally prefer to use the shortened-annotation approach everywhere). We might want a third opinion @sammccall.
I see, I got confusing when reading the EXPECT_REFERENCES_WITH_TYPES("", "", Ambiguous, Ambiguous) code.
Comment Actions Agree there are readability concerns here (long macro names, out-of-line kinds, complicated macros). My suggestion would be to treat RefKind as an optional feature. Most tests would just assert the set of marked locations and test the cases where kind is interesting separately. string markReferences(string TargetCode, string ReferencingCode, bool WithKind); // markReferences("int x;", "int y = ^x;", false) => "int ^x;" // markReferences("int x;", "int y = ^x;", true) => "int $explicit^x;" #define EXPECT_REFS(T, R) EXPECT_EQ(T, markReferences(Annotations(T).code(), R, false)) << R; #define EXPECT_TYPED_REFS(T, R) EXPECT_EQ(T, markReferences(Annotations(T).code(), R, true)) << R;
|
a bug in existing code? by looking at this example, we should use EXPECT_AMBIGUOUS_REFERENCES(Code, Code, RefType::Ambiguous, RefType::Ambiguous, RefType::Ambiguous)