Last active
October 1, 2017 19:56
-
-
Save cmstead/e07dc87c70d326be44e0fe8dd5e5bf4f to your computer and use it in GitHub Desktop.
Example of testing composition of multiply and divide with Quickspec
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
describe('runMultiplyThenDivide', function() { | |
it('should properly evaluate the composition of multiply and divide', function () { | |
const specSet = [ | |
{ | |
name: 'Zero-multiplication', | |
setupValues: { a: 0, b: 1, c: 2 }, | |
expectedValue: 0 | |
}, | |
{ | |
name: 'Multiplicative identity', | |
setupValues: { a: 1, b: 5, c: 2 }, | |
expectedValue: 2.5 | |
}, | |
{ | |
name: 'Multiplying positive numbers', | |
setupValues: { a: 6, b: 7, c: 3 }, | |
expectedValue: 14 | |
}, | |
{ | |
name: 'Multiplying 1 positive, 1 negative number', | |
setupValues: { a: -3, b: 4, c: 6 }, | |
expectedValue: -2 | |
}, | |
{ | |
name: 'Multiplying two negative numbers', | |
setupValues: { a: -5, b: -6, c: 3 }, | |
expectedValue: 10 | |
} | |
]; | |
const runMultiplyThenDivide = ({ a, b }, verify) => verify(multiplyThenDivide(a, b)); | |
quickSpec | |
.verify(runMultiplyThenDivide) | |
.over(specSet); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment