test('isEmpty vs nonEmpty', () => { fc.assert( fc.property(fc.anything(), value => { const option = Option.of(value) return option.isEmpty() !== option.nonEmpty() }), ) })
describe('inheritance', () => { test('instance of Option', () => { fc.assert( fc.property(fc.anything(), value => Option.of(value) instanceof Option), ) }) test('instance of None or Some', () => { fc.assert( fc.property(fc.anything(), value => { const isSome = Option.of(value) instanceof Some const isNone = Option.of(value) instanceof None return isSome || isNone }), ) }) })
describe('nonEmpty values', () => { test('Option must be non-empty', () => { fc.assert(fc.property(nonEmpty(), value => Option.of(value).nonEmpty())) }) test('Option must have a same value', () => { fc.assert( fc.property(nonEmpty(), value => Option.of(value).get() === value), ) }) test('Option must skip getOrElse', () => { fc.assert( fc.property( nonEmpty(), fc.anything(), (value, or) => Option.of(value).getOrElse(or) === value, ), ) }) })