Skip to content
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

Add support for dynamic tests written in Kotlin #238

Merged
merged 3 commits into from Feb 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -13,7 +13,7 @@ public class AttributeStackSelectorTest
@Test
void unrollLambda()
{
String[] methodNames = {"doStuff", "lambda$handleCallback$0"};
String[] methodNames = {"doStuff", "lambda$handleCallback$0", "test_in_kotlin$lambda-1$lambda-0"};
Approvals.verifyAll("unroll lambda", methodNames,
m -> String.format("%s -> %s", m, TestUtils.unrollLambda(m)));
}
Expand Down
Expand Up @@ -3,3 +3,4 @@ unroll lambda

doStuff -> doStuff
lambda$handleCallback$0 -> handleCallback
test_in_kotlin$lambda-1$lambda-0 -> test_in_kotlin
Expand Up @@ -221,12 +221,18 @@ private static String handleInnerClasses(String className)
{
return className.replaceAll("\\$", ".");
}

public static String unrollLambda(String methodName)
{
Pattern p = Pattern.compile("lambda\\$(.*)\\$\\d+");
Matcher m = p.matcher(methodName);
if (m.matches())
{ return m.group(1); }
Matcher javaMatcher = unrollJavaLambdaPattern.matcher(methodName);
if (javaMatcher.matches())
{ return javaMatcher.group(1); }

Matcher kotlinMatcher = unrollKotlinLambdaPattern.matcher(methodName);
if (kotlinMatcher.matches())
{ return kotlinMatcher.group(1); }
return methodName;
}
private static final Pattern unrollJavaLambdaPattern = Pattern.compile("lambda\\$(.*)\\$\\d+");
private static final Pattern unrollKotlinLambdaPattern = Pattern.compile("(.*?)(\\$lambda-\\d+)+");
}