-
Notifications
You must be signed in to change notification settings - Fork 532
Fixed wildcard matching for elements with type information. #5833
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
Changes from 2 commits
24459b9
d675b76
e717136
13f0077
07d31e5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -140,15 +140,49 @@ void matchesUnqualifiedJavaLangArguments() { | |
| void matchesArgumentsWithWildcards() { | ||
| assertTrue(argRegex("A foo(java.util.*)").matcher("java.util.Map").matches()); | ||
| assertTrue(argRegex("A foo(java..*)").matcher("java.util.Map").matches()); | ||
| assertTrue(argRegex("A foo(*.util.*)").matcher("java.util.Map").matches()); | ||
| assertTrue(argRegex("A foo(*..*)").matcher("java.util.Map").matches()); | ||
| } | ||
|
|
||
| @Test | ||
| void matchesExactlyOneWithWildcard() { | ||
| assertTrue(argRegex("A foo(*)").matcher("int").matches()); | ||
| assertTrue(argRegex("A foo(*, int)").matcher("int,int").matches()); | ||
| assertTrue(argRegex("A foo(*, int)").matcher("double,int").matches()); | ||
| assertTrue(argRegex("A foo(int, *)").matcher("int,int").matches()); | ||
| assertTrue(argRegex("A foo(int, *)").matcher("int,double").matches()); | ||
| assertTrue(argRegex("A foo(*, *)").matcher("int,int").matches()); | ||
| assertTrue(argRegex("A foo(int, *, double)").matcher("int,int,double").matches()); | ||
| assertTrue(argRegex("A foo(int, *, double)").matcher("int,double,double").matches()); | ||
|
|
||
| assertFalse(argRegex("A foo(*)").matcher("").matches()); | ||
| assertFalse(argRegex("A foo(*)").matcher("int,int").matches()); | ||
| assertFalse(argRegex("A foo(*, int)").matcher("int").matches()); | ||
| assertFalse(argRegex("A foo(*, int)").matcher("int,double").matches()); | ||
| assertFalse(argRegex("A foo(int, *)").matcher("int").matches()); | ||
| assertFalse(argRegex("A foo(int, *)").matcher("double,int").matches()); | ||
| assertFalse(argRegex("A foo(*, *)").matcher("").matches()); | ||
| assertFalse(argRegex("A foo(*, *)").matcher("int").matches()); | ||
| assertFalse(argRegex("A foo(int, *, double)").matcher("int,double").matches()); | ||
| assertFalse(argRegex("A foo(int, *, double)").matcher("double,int,double").matches()); | ||
| } | ||
|
|
||
| @Test | ||
| void matchesArgumentsWithDotDot() { | ||
| assertTrue(argRegex("A foo(.., int)").matcher("int").matches()); | ||
| assertTrue(argRegex("A foo(.., int)").matcher("int,int").matches()); | ||
| assertTrue(argRegex("A foo(.., int)").matcher("double,int").matches()); | ||
| assertFalse(argRegex("A foo(.., int)").matcher("int,double").matches()); | ||
|
Jenson3210 marked this conversation as resolved.
|
||
|
|
||
| assertTrue(argRegex("A foo(int, ..)").matcher("int").matches()); | ||
| assertTrue(argRegex("A foo(int, ..)").matcher("int,int").matches()); | ||
| assertTrue(argRegex("A foo(int, ..)").matcher("int,double").matches()); | ||
| assertFalse(argRegex("A foo(int, ..)").matcher("double,int").matches()); | ||
|
|
||
| assertTrue(argRegex("A foo(int, .., double)").matcher("int,double").matches()); | ||
| assertTrue(argRegex("A foo(int, .., double)").matcher("int,int,double").matches()); | ||
| assertTrue(argRegex("A foo(int, .., double)").matcher("int,double,double").matches()); | ||
| assertFalse(argRegex("A foo(int, .., double)").matcher("double,int,double").matches()); | ||
|
|
||
| assertTrue(argRegex("A foo(..)").matcher("").matches()); | ||
| assertTrue(argRegex("A foo(..)").matcher("int").matches()); | ||
|
|
@@ -404,6 +438,11 @@ void matchUnknownTypesWildcardArguments() { | |
| void matchUnknownTypesSingleWildcardArgument() { | ||
| var mi = asMethodInvocation("Assert.assertTrue(Foo.bar(), \"message\");"); | ||
| assertTrue(new MethodMatcher("org.junit.Assert assertTrue(*, String)").matches(mi, true)); | ||
| assertTrue(new MethodMatcher("org.junit.Assert assertTrue(*, java.lang.String)").matches(mi, true)); | ||
| assertTrue(new MethodMatcher("org.junit.Assert assertTrue(String, *)").matches(mi, true)); | ||
| assertTrue(new MethodMatcher("org.junit.Assert assertTrue(double, *)").matches(mi, true)); | ||
| assertTrue(new MethodMatcher("org.junit.Assert assertTrue(java.lang.String, *)").matches(mi, true)); | ||
|
Comment on lines
+453
to
+455
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These three assertions surprise me. In this test the type of
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess that is how |
||
| assertTrue(new MethodMatcher("org.junit.Assert assertTrue(*, *)").matches(mi, true)); | ||
| } | ||
|
|
||
| static J.MethodInvocation asMethodInvocation(String code) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.