From 484b21f34d18776047ca9e1f013f46636d4543fd Mon Sep 17 00:00:00 2001 From: Uzi Landsmann Date: Sat, 5 Oct 2019 08:11:18 +0200 Subject: [PATCH 1/3] Bumped hamming to 2.3.0 and changed the tests according to https://raw.githubusercontent.com/exercism/problem-specifications/master/exercises/hamming/canonical-data.json --- .../.meta/src/reference/kotlin/Hamming.kt | 2 +- exercises/hamming/.meta/version | 2 +- .../hamming/src/test/kotlin/HammingTest.kt | 69 +++---------------- 3 files changed, 12 insertions(+), 61 deletions(-) diff --git a/exercises/hamming/.meta/src/reference/kotlin/Hamming.kt b/exercises/hamming/.meta/src/reference/kotlin/Hamming.kt index 8fdcf903..1edeb9ac 100644 --- a/exercises/hamming/.meta/src/reference/kotlin/Hamming.kt +++ b/exercises/hamming/.meta/src/reference/kotlin/Hamming.kt @@ -1,7 +1,7 @@ object Hamming { fun compute(leftStrand: String, rightStrand: String): Int { - require(leftStrand.length == rightStrand.length, {"left and right strands must be of equal length."}) + require(leftStrand.length == rightStrand.length, {"left and right strands must be of equal length"}) val commonPairs = leftStrand.zip(rightStrand) return commonPairs.count { it.first != it.second } diff --git a/exercises/hamming/.meta/version b/exercises/hamming/.meta/version index 7ec1d6db..276cbf9e 100644 --- a/exercises/hamming/.meta/version +++ b/exercises/hamming/.meta/version @@ -1 +1 @@ -2.1.0 +2.3.0 diff --git a/exercises/hamming/src/test/kotlin/HammingTest.kt b/exercises/hamming/src/test/kotlin/HammingTest.kt index d12712df..8e9d0685 100644 --- a/exercises/hamming/src/test/kotlin/HammingTest.kt +++ b/exercises/hamming/src/test/kotlin/HammingTest.kt @@ -17,92 +17,43 @@ class HammingTest { @Ignore @Test - fun noDistanceBetweenShortIdenticalStrands() { + fun noDistanceBetweenSingleLetterIdenticalStrands() { assertEquals(0, Hamming.compute("A", "A")) } @Ignore @Test - fun noDistanceBetweenLongIdenticalStrands() { - assertEquals(0, Hamming.compute("GGACTGA", "GGACTGA")) - } - - @Ignore - @Test - fun completeDistanceInSingleNucleotideStrand() { - assertEquals(1, Hamming.compute("A", "G")) - } - - @Ignore - @Test - fun completeDistanceInSmallStrand() { - assertEquals(2, Hamming.compute("AG", "CT")) + fun completeDistanceInSingleLetterDifferentStrands() { + assertEquals(1, Hamming.compute("G", "T")) } @Ignore @Test - fun smallDistanceInSmallStrand() { - assertEquals(1, Hamming.compute("AT", "CT")) - } - - @Ignore - @Test - fun smallDistanceInMediumStrand() { - assertEquals(1, Hamming.compute("GGACG", "GGTCG")) - } - - @Ignore - @Test - fun smallDistanceInLongStrand() { - assertEquals(2, Hamming.compute("ACCAGGG", "ACTATGG")) - } - - @Ignore - @Test - fun nonUniqueCharacterInFirstStrand() { - assertEquals(1, Hamming.compute("AAG", "AAA")) - } - - @Ignore - @Test - fun nonUniqueCharacterInSecondStrand() { - assertEquals(1, Hamming.compute("AAA", "AAG")) - } - - @Ignore - @Test - fun sameNucleotidesInDifferentPositions() { - assertEquals(2, Hamming.compute("TAG", "GAT")) - } - - @Ignore - @Test - fun largeDistanceInPermutedStrand() { - assertEquals(4, Hamming.compute("GATACA", "GCATAA")) + fun noDistanceBetweenLongIdenticalStrands() { + assertEquals(0, Hamming.compute("GGACTGAAATCTG", "GGACTGAAATCTG")) } @Ignore @Test - fun largeDistanceInOffByOneStrand() { + fun largeDistanceBetweenLongDifferentStrands() { assertEquals(9, Hamming.compute("GGACGGATTCTG", "AGGACGGATTCT")) } @Ignore @Test - fun validatesFirstStrandNotLonger() { + fun disallowFirstStrandLonger() { expectedException.expect(IllegalArgumentException::class.java) - expectedException.expectMessage("left and right strands must be of equal length.") + expectedException.expectMessage("left and right strands must be of equal length") Hamming.compute("AATG", "AAA") } @Ignore @Test - fun validatesSecondStrandNotLonger() { + fun disallowSecondStrandLonger() { expectedException.expect(IllegalArgumentException::class.java) - expectedException.expectMessage("left and right strands must be of equal length.") + expectedException.expectMessage("left and right strands must be of equal length") Hamming.compute("ATA", "AGTG") } - } From 0e2094d406a3f2139b034e4165cf28a7e1eec751 Mon Sep 17 00:00:00 2001 From: Uzi Landsmann Date: Sun, 6 Oct 2019 06:59:43 +0200 Subject: [PATCH 2/3] Changed travis jdk to openjdk11 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f1fd0804..f8f6a0ac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ --- language: java jdk: - - oraclejdk8 + - openjdk11 env: - SCRIPT=bin/unit-tests.sh From b85d9f8ec6f0f96be133caad920b55d855e35836 Mon Sep 17 00:00:00 2001 From: Uzi Landsmann Date: Sat, 19 Oct 2019 09:10:55 +0200 Subject: [PATCH 3/3] Updated hamming test names --- exercises/hamming/src/test/kotlin/HammingTest.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/exercises/hamming/src/test/kotlin/HammingTest.kt b/exercises/hamming/src/test/kotlin/HammingTest.kt index 8e9d0685..70adce2e 100644 --- a/exercises/hamming/src/test/kotlin/HammingTest.kt +++ b/exercises/hamming/src/test/kotlin/HammingTest.kt @@ -11,37 +11,37 @@ class HammingTest { var expectedException: ExpectedException = ExpectedException.none() @Test - fun noDistanceBetweenEmptyStrands() { + fun `empty strands`() { assertEquals(0, Hamming.compute("", "")) } @Ignore @Test - fun noDistanceBetweenSingleLetterIdenticalStrands() { + fun `single letter identical strands`() { assertEquals(0, Hamming.compute("A", "A")) } @Ignore @Test - fun completeDistanceInSingleLetterDifferentStrands() { + fun `single letter different strands`() { assertEquals(1, Hamming.compute("G", "T")) } @Ignore @Test - fun noDistanceBetweenLongIdenticalStrands() { + fun `long identical strands`() { assertEquals(0, Hamming.compute("GGACTGAAATCTG", "GGACTGAAATCTG")) } @Ignore @Test - fun largeDistanceBetweenLongDifferentStrands() { + fun `long different strands`() { assertEquals(9, Hamming.compute("GGACGGATTCTG", "AGGACGGATTCT")) } @Ignore @Test - fun disallowFirstStrandLonger() { + fun `disallow first strand longer`() { expectedException.expect(IllegalArgumentException::class.java) expectedException.expectMessage("left and right strands must be of equal length") @@ -50,7 +50,7 @@ class HammingTest { @Ignore @Test - fun disallowSecondStrandLonger() { + fun `disallow second strand longer`() { expectedException.expect(IllegalArgumentException::class.java) expectedException.expectMessage("left and right strands must be of equal length")