From e572a5399ca6e12f364e13422897a646c3441e14 Mon Sep 17 00:00:00 2001 From: Geoffrey Challen Date: Wed, 9 Jun 2021 08:57:06 -0500 Subject: [PATCH] Fix string bug. --- .idea/detekt.xml | 2 +- build.gradle.kts | 2 +- src/main/kotlin/generators/Type.kt | 3 ++- .../illinois/cs/cs125/jenisol/core/TestJavaExamples.kt | 3 +++ .../java/noreceiver/twostringequality/Correct.java | 9 +++++++++ .../java/noreceiver/twostringequality/Incorrect0.java | 10 ++++++++++ 6 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 src/test/java/examples/java/noreceiver/twostringequality/Correct.java create mode 100644 src/test/java/examples/java/noreceiver/twostringequality/Incorrect0.java diff --git a/.idea/detekt.xml b/.idea/detekt.xml index 8ae91d8..40fb4ae 100644 --- a/.idea/detekt.xml +++ b/.idea/detekt.xml @@ -3,6 +3,6 @@ true true - $PROJECT_DIR$/config/detekt/detekt.yml + $PROJECT_DIR$/../questioner-examples/config/detekt/detekt.yml \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index adb88b8..9eedbbd 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -37,7 +37,7 @@ tasks.withType { tasks.withType { useJUnitPlatform() enableAssertions = true - jvmArgs("-ea", "-Xmx1G", "-Xss256k") + jvmArgs("-ea", "-Xmx1G", "-Xss256k", "-Dfile.encoding=UTF-8") } tasks.dependencyUpdates { fun String.isNonStable() = !( diff --git a/src/main/kotlin/generators/Type.kt b/src/main/kotlin/generators/Type.kt index c0adb89..df0e120 100644 --- a/src/main/kotlin/generators/Type.kt +++ b/src/main/kotlin/generators/Type.kt @@ -510,7 +510,8 @@ class CharGenerator(random: Random) : TypeGenerators(random) { class StringGenerator(random: Random) : TypeGenerators(random) { - override val simple = setOf("t", "gwa", "8 circle", "").values(ZeroComplexity) + override val simple = + setOf("t", "gwa", "8 circle", "").map { it.toCharArray() }.map { String(it) }.toSet().values(ZeroComplexity) override val edge = listOf(null).values(ZeroComplexity) override fun random(complexity: Complexity, runner: TestRunner?) = random(complexity, random).value(complexity) diff --git a/src/test/java/edu/illinois/cs/cs125/jenisol/core/TestJavaExamples.kt b/src/test/java/edu/illinois/cs/cs125/jenisol/core/TestJavaExamples.kt index 53fa137..60f4c5c 100644 --- a/src/test/java/edu/illinois/cs/cs125/jenisol/core/TestJavaExamples.kt +++ b/src/test/java/edu/illinois/cs/cs125/jenisol/core/TestJavaExamples.kt @@ -268,6 +268,9 @@ class TestJavaExamples : StringSpec( examples.java.receiver.actuallystatic.Correct::class.java.also { "${it.testName()}" { it.test() } } + examples.java.noreceiver.twostringequality.Correct::class.java.also { + "${it.testName()}" { it.test() } + } examples.java.receiver.timeouttest.Correct::class.java.also { "${it.testName()}" { val runnable = object : Runnable { diff --git a/src/test/java/examples/java/noreceiver/twostringequality/Correct.java b/src/test/java/examples/java/noreceiver/twostringequality/Correct.java new file mode 100644 index 0000000..3553b3b --- /dev/null +++ b/src/test/java/examples/java/noreceiver/twostringequality/Correct.java @@ -0,0 +1,9 @@ +package examples.java.noreceiver.twostringequality; + +public class Correct { + public static boolean equals(String first, String second) { + assert first != null; + assert second != null; + return first.equals(second); + } +} diff --git a/src/test/java/examples/java/noreceiver/twostringequality/Incorrect0.java b/src/test/java/examples/java/noreceiver/twostringequality/Incorrect0.java new file mode 100644 index 0000000..7873911 --- /dev/null +++ b/src/test/java/examples/java/noreceiver/twostringequality/Incorrect0.java @@ -0,0 +1,10 @@ +package examples.java.noreceiver.twostringequality; + +@SuppressWarnings("StringEquality") +public class Incorrect0 { + public static boolean equals(String first, String second) { + assert first != null; + assert second != null; + return first == second; + } +}