From ed98133b8f7099674a987b4ab43b1cb07e5aed1a Mon Sep 17 00:00:00 2001 From: Geoffrey Challen Date: Sat, 22 Oct 2022 08:41:10 -0500 Subject: [PATCH] Fix lambda bug. --- build.gradle.kts | 2 +- ....illinois.cs.cs125.jeed.containerrunner.version | 2 +- core/src/main/kotlin/JavaComplexity.kt | 2 +- .../edu.illinois.cs.cs125.jeed.core.version | 2 +- core/src/test/kotlin/TestJavaComplexity.kt | 12 ++++++++++++ core/src/test/kotlin/TestJavaFeatures.kt | 14 ++++++++++++++ core/src/test/kotlin/TestKotlinComplexity.kt | 12 ++++++++++++ .../edu.illinois.cs.cs125.jeed.server.version | 2 +- 8 files changed, 43 insertions(+), 5 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index b091bbf6..5718100b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -18,7 +18,7 @@ allprojects { } subprojects { group = "com.github.cs125-illinois.jeed" - version = "2022.10.4" + version = "2022.10.5" tasks.withType { useJUnitPlatform() enableAssertions = true diff --git a/containerrunner/src/main/resources/edu.illinois.cs.cs125.jeed.containerrunner.version b/containerrunner/src/main/resources/edu.illinois.cs.cs125.jeed.containerrunner.version index f50b44e7..28b36ad5 100644 --- a/containerrunner/src/main/resources/edu.illinois.cs.cs125.jeed.containerrunner.version +++ b/containerrunner/src/main/resources/edu.illinois.cs.cs125.jeed.containerrunner.version @@ -1 +1 @@ -version=2022.10.4 \ No newline at end of file +version=2022.10.5 \ No newline at end of file diff --git a/core/src/main/kotlin/JavaComplexity.kt b/core/src/main/kotlin/JavaComplexity.kt index b4a32d7d..6b71cb54 100644 --- a/core/src/main/kotlin/JavaComplexity.kt +++ b/core/src/main/kotlin/JavaComplexity.kt @@ -159,7 +159,7 @@ class JavaComplexityListener(val source: Source, entry: Map.Entry value + 1; +} +""".trim() + ).complexity() + } }) diff --git a/core/src/test/kotlin/TestJavaFeatures.kt b/core/src/test/kotlin/TestJavaFeatures.kt index 8093fad0..c8e1de44 100644 --- a/core/src/test/kotlin/TestJavaFeatures.kt +++ b/core/src/test/kotlin/TestJavaFeatures.kt @@ -985,4 +985,18 @@ public static IWhichHemisphere create(Position p) { featureMap[FeatureName.ANONYMOUS_CLASSES] shouldBe 3 } } + "should allow top-level lambda methods" { + Source.fromJavaSnippet( + """ +public interface Modify { + int modify(int value); +} +public class Modifier { + Modify modify = value -> value + 1; +} +""".trim() + ).features().check("") { + featureMap[FeatureName.LAMBDA_EXPRESSIONS] shouldBe 1 + } + } }) diff --git a/core/src/test/kotlin/TestKotlinComplexity.kt b/core/src/test/kotlin/TestKotlinComplexity.kt index 4d4c8273..c3deffb3 100644 --- a/core/src/test/kotlin/TestKotlinComplexity.kt +++ b/core/src/test/kotlin/TestKotlinComplexity.kt @@ -759,4 +759,16 @@ class Main { it.lookupFile("Main.kt") shouldBe 3 } } + "should allow top-level lambda methods" { + Source.fromKotlinSnippet( + """ +fun interface Modify { + fun modify(value: Int): Int +} +class Modifier { + val modify = Modify { value -> value + 1 } +} +""".trim() + ).complexity() + } }) diff --git a/server/src/main/resources/edu.illinois.cs.cs125.jeed.server.version b/server/src/main/resources/edu.illinois.cs.cs125.jeed.server.version index f50b44e7..28b36ad5 100644 --- a/server/src/main/resources/edu.illinois.cs.cs125.jeed.server.version +++ b/server/src/main/resources/edu.illinois.cs.cs125.jeed.server.version @@ -1 +1 @@ -version=2022.10.4 \ No newline at end of file +version=2022.10.5 \ No newline at end of file