-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
747652d
commit 8df5d6c
Showing
2 changed files
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module Trip (zeroFuel) where | ||
|
||
-- https://www.codewars.com/kata/5861d28f124b35723e00005e/train/haskell | ||
|
||
zeroFuel :: Int -> Int -> Int -> Bool | ||
zeroFuel distanceToPump mpg fuelLeft = distanceToPump `div` fuelLeft <= mpg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module TripSpec where | ||
|
||
import Test.Hspec | ||
import Test.HUnit (assertBool) | ||
import Trip (zeroFuel) | ||
|
||
spec :: Spec | ||
spec = do | ||
describe "Fixed Tests" $ do | ||
it "zeroFuel 50 25 2" $ do | ||
assertBool "2 gallons is enough fuel to drive 50 miles at 25 miles per gallon" $ zeroFuel 50 25 2 | ||
it "zeroFuel 60 30 3" $ do | ||
assertBool "3 gallons is enough fuel to drive 60 miles at 30 miles per gallon" $ zeroFuel 60 30 3 | ||
it "zeroFuel 70 25 1" $ do | ||
assertBool "1 gallon is not enough fuel to drive 70 miles at 25 miles per gallon" $ not $ zeroFuel 70 25 1 | ||
it "zeroFuel 100 25 3" $ do | ||
assertBool "3 gallons is not enough fuel to drive 100 miles at 25 miles per gallon" $ not $ zeroFuel 100 25 3 |