-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Improve completions testing #23591
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve completions testing #23591
Conversation
61b751c
to
feb1c62
Compare
👍 would like to get other's feeling about the API flow in general. pinging @sheetalkamat, @rbuckton, @sandersn, @RyanCavanaugh and @amcasey. I also believe this should be faster running the tests, instead of requiring for the same completions multiple times. |
There is a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor feedback.
readonly sourceDisplay?: string, | ||
}; | ||
|
||
type Many<T> = T | ReadonlyArray<T>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I find it confusing that "Many" might be mean "one". I might have called it "OneOrMore".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be 0 though... this is just a slightly less verbose way of writing an array. How about ArrayOrSingle
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, I guess I'm not sure I understand why we're not just using an array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In many places (such as at
) there's usually only one element, so it saves a lot of typing. This type is usually converted using toArray
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I didn't think about the call site. In Roslyn, we had something similar, but it was a way to avoid allocating the array, which didn't seem to be (and isn't) a concern here. Yeah, I like ArrayOrSingle
.
export interface VerifyCompletionsOptions { | ||
readonly at?: Many<string>; | ||
readonly isNewIdentifierLocation?: boolean; | ||
readonly are?: Many<ExpectedCompletionEntry>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find the name "at" a little unclear and the name "are" very unclear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at
could be atMarker
-- not sure what to replace are
with -- it's what the completions are. areExactly
? Keep in mind the name will appear thousands of times so we don't want it to get too long. How about exact
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured out what they meant by reading the tests, but I still find the names unclear. I would have expected something like location
or marker
for at
and something like all
or exact
for are
(or a flag indicating that includes
is exhaustive).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
marker
and exact
sound good.
return; | ||
public verifyCompletions(options: FourSlashInterface.VerifyCompletionsOptions) { | ||
if (options.at !== undefined) { | ||
if (typeof options.at === "string") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this could be a helper function that operates on Many<T>
?
this.verifyCompletionEntry(found, include); | ||
} | ||
} | ||
else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are includes
and excludes
mutually exclusive?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, good catch!
verify.completionsListContains("x", undefined, undefined, undefined, undefined, undefined, { includeCompletionsForModuleExports: true });
(This gets more annoying as we add more options.)hasAction
andsourceDisplay
are undefined if not mentioned in the test.(Also discovered Duplicate completion entries for
undefined
#23587 and Completion details kind disagrees with entry kind #23594)