From 02a849ef6d4423652f250108d7aae39e78f7a9e6 Mon Sep 17 00:00:00 2001 From: tqa236 Date: Wed, 30 Jan 2019 15:11:42 +0100 Subject: [PATCH 1/3] Add a test case to avoid wrong recursion solution. This solution will pass all the current test but fail on the new one: ``` module Hamming (distance) where distance :: String -> String -> Maybe Int distance [] [] = Just 0 distance (x:xs) (y:ys) | length(xs) /= length(ys) = Nothing | x /= y = fmap (1 + ) (distance xs ys) | x == y = distance xs ys ``` --- exercises/hamming/test/Tests.hs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/exercises/hamming/test/Tests.hs b/exercises/hamming/test/Tests.hs index 61367baa4..43663fcc0 100644 --- a/exercises/hamming/test/Tests.hs +++ b/exercises/hamming/test/Tests.hs @@ -61,4 +61,9 @@ cases = [ Case { description = "empty strands" , strand2 = "AGTG" , expected = Nothing } + , Case { description = "disallow only one empty strand" + , strand1 = "" + , strand2 = "G" + , expected = Nothing + } ] From e36279402bfff74cf5ef832215419280d7b92e62 Mon Sep 17 00:00:00 2001 From: tqa236 Date: Fri, 1 Feb 2019 11:00:14 +0100 Subject: [PATCH 2/3] Update package.yaml Update test version --- exercises/hamming/package.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/hamming/package.yaml b/exercises/hamming/package.yaml index 171179b05..2f43e5270 100644 --- a/exercises/hamming/package.yaml +++ b/exercises/hamming/package.yaml @@ -1,5 +1,5 @@ name: hamming -version: 2.2.0.9 +version: 2.3.0.10 dependencies: - base From edeb5a77fb6414598c96fda949e46c5a4fbe69f8 Mon Sep 17 00:00:00 2001 From: tqa236 Date: Thu, 7 Feb 2019 08:38:20 +0100 Subject: [PATCH 3/3] Add 2 new test cases about empty strand --- exercises/hamming/test/Tests.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/exercises/hamming/test/Tests.hs b/exercises/hamming/test/Tests.hs index 43663fcc0..480cbce55 100644 --- a/exercises/hamming/test/Tests.hs +++ b/exercises/hamming/test/Tests.hs @@ -61,9 +61,14 @@ cases = [ Case { description = "empty strands" , strand2 = "AGTG" , expected = Nothing } - , Case { description = "disallow only one empty strand" + , Case { description = "disallow left empty strand" , strand1 = "" , strand2 = "G" , expected = Nothing } + , Case { description = "disallow right empty strand" + , strand1 = "G" + , strand2 = "" + , expected = Nothing + } ]