Skip to content

Commit 473b7b3

Browse files
tqa236sshine
authored andcommitted
Hamming 2.3.0.10: Add empty strand test cases (#796)
The following solution passes all the current tests but fail on the new ones: 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 The problem is insufficient pattern matching against an empty strand. This PR adds two test cases that address the possibility that one strand is empty and the other one isn't. This PR addresses exercism/problem-specifications#1450
1 parent 25d1d2e commit 473b7b3

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

exercises/hamming/package.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: hamming
2-
version: 2.2.0.9
2+
version: 2.3.0.10
33

44
dependencies:
55
- base

exercises/hamming/test/Tests.hs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,14 @@ cases = [ Case { description = "empty strands"
6161
, strand2 = "AGTG"
6262
, expected = Nothing
6363
}
64+
, Case { description = "disallow left empty strand"
65+
, strand1 = ""
66+
, strand2 = "G"
67+
, expected = Nothing
68+
}
69+
, Case { description = "disallow right empty strand"
70+
, strand1 = "G"
71+
, strand2 = ""
72+
, expected = Nothing
73+
}
6474
]

0 commit comments

Comments
 (0)