Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sum-of-multiples: Explicitly pass [3, 5] instead of defaulting #101

Merged
merged 1 commit into from
Mar 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions sum-of-multiples/example.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
module SumOfMultiples (sumOfMultiples, sumOfMultiplesDefault) where

sumOfMultiplesDefault :: Int -> Int
sumOfMultiplesDefault = sumOfMultiples [3, 5]
module SumOfMultiples (sumOfMultiples) where

sumOfMultiples :: [Int] -> Int -> Int
sumOfMultiples targets upperBound = sum (filter f [1..upperBound-1])
Expand Down
10 changes: 5 additions & 5 deletions sum-of-multiples/sum-of-multiples_test.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Test.HUnit (Assertion, (@=?), runTestTT, Test(..), Counts(..))
import System.Exit (ExitCode(..), exitWith)
import SumOfMultiples (sumOfMultiples, sumOfMultiplesDefault)
import SumOfMultiples (sumOfMultiples)

exitProperly :: IO Counts -> IO ()
exitProperly m = do
Expand All @@ -18,13 +18,13 @@ main = exitProperly $ runTestTT $ TestList
sumOfMultiplesTests :: [Test]
sumOfMultiplesTests =
[ testCase "1" $
0 @=? sumOfMultiplesDefault 1
0 @=? sumOfMultiples [3, 5] 1
, testCase "4" $
3 @=? sumOfMultiplesDefault 4
3 @=? sumOfMultiples [3, 5] 4
, testCase "10" $
23 @=? sumOfMultiplesDefault 10
23 @=? sumOfMultiples [3, 5] 10
, testCase "1000" $
233168 @=? sumOfMultiplesDefault 1000
233168 @=? sumOfMultiples [3, 5] 1000
, testCase "[7, 13, 17] 20" $
51 @=? sumOfMultiples [7, 13, 17] 20
, testCase "[4, 6] 15" $
Expand Down