Last active
March 15, 2017 06:58
-
-
Save MattMcFarland/e07cb064c5212a9ebcaa4d87f5696981 to your computer and use it in GitHub Desktop.
An example of what happens when JS Verify fails a test
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
const jsc = require('jsverify') | |
// With property based testing, we don't check for specific inputs and outputs, instead we are testing the boundaries of our code. | |
const additionIsCommunative = jsc.checkForall(jsc.integer, jsc.integer, | |
(a, b) => a + b === b + a) | |
const multiplicationIsDistributive = jsc.checkForall(jsc.integer, jsc.integer, jsc.integer, | |
(a, b, c) => a * (b + c) === a * b + a * c) | |
const subtractionIsCommutative = jsc.checkForall(jsc.integer, jsc.integer, | |
(a, b) => a - b === b - a) | |
// log out whether or not the test passed | |
console.log({ additionIsCommunative, multiplicationIsDistributive, subtractionIsCommutative }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment