Created
July 20, 2012 03:30
-
-
Save ryan-scott-dev/3148481 to your computer and use it in GitHub Desktop.
Haskell Bowling Score Calculator Harness
This file contains hidden or 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
import System.IO | |
calculateScore x = 0 | |
testDescription 1 = print "Testing score with [(1,5)] == 6" | |
testDescription 2 = print "Testing score with [(1,5), (3, 5), (7, 2)] == 23" | |
testDescription 3 = print "Testing a spare of [(1,5), (5, 5), (7, 2)] == 31" | |
testDescription 4 = print "Testing a strike with [(1,5), (10, 0), (7, 2)] == 34" | |
testDescription 5 = print "Testing a perfect game with 12 [(10,0)] == 300" | |
testDescription 6 = print "Testing a game with all spares with 10 (5,5) and one (5,0) == 150" | |
testFunction 1 = calculateScore [(1,5)] | |
testFunction 2 = calculateScore [(1,5), (3, 5), (7, 2)] | |
testFunction 3 = calculateScore [(1,5), (5, 5), (7, 2)] | |
testFunction 4 = calculateScore [(1,5), (10, 0), (7, 2)] | |
testFunction 5 = calculateScore [(10, 0), (10, 0), (10, 0), (10, 0), (10, 0), (10, 0), (10, 0), (10, 0), (10, 0), (10, 0), (10, 0), (10, 0)] | |
testFunction 6 = calculateScore [(5, 5), (5, 5), (5, 5), (5, 5), (5, 5), (5, 5), (5, 5), (5, 5), (5, 5), (5, 5), (5, 0)] | |
testValidation(1,6) = print "Test 1 Passed" | |
testValidation(2,23) = print "Test 2 Passed" | |
testValidation(3,31) = print "Test 3 Passed" | |
testValidation(4,34) = print "Test 4 Passed" | |
testValidation(5,300) = print "Test 5 Passed" | |
testValidation(6,150) = print "Test 6 Passed" | |
testValidation(x,y) = print ("Test " ++ show(x) ++ " Failed") | |
test x = do | |
testDescription x | |
testValidation(x,(testFunction x)) | |
runTest = do | |
test 1 | |
test 2 | |
test 3 | |
test 4 | |
test 5 | |
test 6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment