Last active
June 15, 2021 18:46
-
-
Save stungeye/60252c720aae38fd549a282b809af3ed to your computer and use it in GitHub Desktop.
Will you, Won't You Starter Code
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
function passOrFail(predicate, expectation, msg) { | |
const outcome = (predicate == expectation) ? "PASSED" : "FAILED"; | |
console.log(`${msg}: ${outcome}`); | |
} | |
function expect(predicate, msg) { | |
return { | |
toBeFalsy: () => passOrFail(predicate, false, msg), | |
toBeTruthy: () => passOrFail(predicate, true, msg) | |
} | |
} | |
function testSuite() { | |
expect(shouldIAnswerThePhone(false, false, false), '!morning !mom !asleep (answer)').toBeTruthy(); | |
expect(shouldIAnswerThePhone(false, false, true), '!morning !mom asleep (!answer)').toBeFalsy(); | |
expect(shouldIAnswerThePhone(false, true, false), '!morning mom !asleep (answer)').toBeTruthy(); | |
expect(shouldIAnswerThePhone(false, true, true), '!morning mom asleep (!answer)').toBeFalsy(); | |
expect(shouldIAnswerThePhone(true, false, false), 'morning !mom !asleep (!answer)').toBeFalsy(); | |
expect(shouldIAnswerThePhone(true, false, true), 'morning !mom asleep (!answer)').toBeFalsy(); | |
expect(shouldIAnswerThePhone(true, true, false), 'morning mom !asleep (answer)').toBeTruthy(); | |
expect(shouldIAnswerThePhone(true, true, true), 'morning mom asleep (!answer)').toBeFalsy(); | |
} | |
function shouldIAnswerThePhone(isMorning, isMom, isAsleep) { | |
// Return true if you answer the phone, otherwise return false. | |
// Rules for answering the phone are found in the question text. | |
}; | |
function setup() { | |
testSuite(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment