Created
June 11, 2018 19:01
-
-
Save kantord/bbe39c18c96ab1b13cafa98b094a4e45 to your computer and use it in GitHub Desktop.
milestone3.js
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
// @flow | |
type Environment = { | |
+left: ?number, | |
+right: ?number, | |
} | |
type AssertionValues = { | |
+result: ?number, | |
} | |
describe( | |
'Min', | |
Suite.Function( | |
(_: Specimen) => ({ | |
[_(it)]: (environment: Environment) => require('./Min'), | |
...({left, right}: Environment, {result}: AssertionValues) => ({ | |
result: Min => expect(Min(left, right)).toEqual(result), | |
error: Min => expect(() => Min(left, right)).toThrow(), | |
}), | |
}), | |
(_: Experiment) => | |
_.with( | |
{ | |
left: 4, | |
}, | |
_ => _.and({right: 6}).produces({result: 4}), | |
_ => _.and({right: 3}).produces({result: 3}), | |
_ => _.and({right: 'asd'}).produces('error'), | |
), | |
(_: Experiment) => | |
_.taking('left').from([null, undefined, 'foo'], _ => | |
_.and('right') | |
.sample(3) // .sample takes the first 3 numbers from iterable | |
.example() // example takes one random element from the sample every time | |
.from(Suite.Integers) | |
.produces('error'), | |
), | |
), | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment