Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should be able to compute a dependency tree for any package of the registry', () =>
fc.assert(
fc.asyncProperty(AllPackagesArbitrary, fc.scheduler(), async (packages, s) => {
// Arrange
const selectedPackage = Object.keys(packages)[0];
const fetch: (name: string) => Promise = s.scheduleFunction(function fetch(packageName) {
return Promise.resolve(packages[packageName]);
});
// Act
dependencyTree(selectedPackage, fetch); // without bugs
// dependencyTree(selectedPackage, fetch, true); // or with bugs
// Assert
let numQueries = 0;
while (s.count() !== 0) {
if (++numQueries > 2 * Object.keys(packages).length) {
throw new Error(`Too many queries`);
it("fork/join is the same result as initial", () =>
fc.assert(
fc.asyncProperty(
arbEitherIO(fc.string(), fc.integer()),
(inner) => eqvIO(
io.result(inner),
io.chain(io.fork(inner), (fiber) => fiber.wait)
)
),
{ verbose: true }
)
);
t.notThrows(() => {
fc.assert(isEquivalentToDeriveUncompressedThenCompress);
});
const equivalentToSecp256k1Node = fc.property(
return liftEq => {
applicativeM(arb => arb.map(M.of), liftEq)
const Sc = liftEq(eqBoolean)
const arbFa = fc.string().map(M.of)
const afb = (s: string) => M.of(s.length)
const bfc = (n: number) => M.of(n > 2)
const associativity = fc.property(arbFa, laws.chain.associativity(M, Sc, afb, bfc))
const Sb = liftEq(eqNumber)
const fab = M.of((a: string) => a.length)
const derivedAp = fc.property(arbFa, laws.chain.derivedAp(M, Sb, fab))
fc.assert(associativity)
fc.assert(derivedAp)
const arb = fc.string().map(M.of)
const Sa = liftEq(eqString)
const leftIdentity = fc.property(fc.string(), laws.monad.leftIdentity(M, Sb, afb))
const rightIdentity = fc.property(arb, laws.monad.rightIdentity(M, Sa))
const ab = (s: string) => s.length
const derivedMap = fc.property(arb, laws.monad.derivedMap(M, Sb, ab))
fc.assert(leftIdentity)
fc.assert(rightIdentity)
fc.assert(derivedMap)
}
}
export const semiring = <a>(S: Semiring</a><a>, E: Eq</a><a>, arb: fc.Arbitrary</a><a>, seed?: number): void => {
const addAssociativity = fc.property(arb, arb, arb, laws.semiring.addAssociativity(S, E))
const addIdentity = fc.property(arb, laws.semiring.addIdentity(S, E))
const commutativity = fc.property(arb, arb, laws.semiring.commutativity(S, E))
const mulAssociativity = fc.property(arb, arb, arb, laws.semiring.mulAssociativity(S, E))
const mulIdentity = fc.property(arb, laws.semiring.mulIdentity(S, E))
const leftDistributivity = fc.property(arb, arb, arb, laws.semiring.leftDistributivity(S, E))
const rightDistributivity = fc.property(arb, arb, arb, laws.semiring.rightDistributivity(S, E))
const annihilation = fc.property(arb, laws.semiring.annihilation(S, E))
fc.assert(addAssociativity, { seed })
fc.assert(addIdentity, { seed })
fc.assert(commutativity, { seed })
fc.assert(mulAssociativity, { seed })
fc.assert(mulIdentity, { seed })
fc.assert(leftDistributivity, { seed })
fc.assert(rightDistributivity, { seed })
fc.assert(annihilation, { seed })
}
</a>
t.notThrows(() => {
fc.assert(equivalentToElliptic);
});
});
return (lift, liftEq) => {
applyF(lift, liftEq)
const arbFa = lift(fc.string())
const Sa = liftEq(eqString)
const Sb = liftEq(eqNumber)
const identity = fc.property(arbFa, laws.applicative.identity(F, Sa))
const ab = (s: string) => s.length
const homomorphism = fc.property(fc.string(), laws.applicative.homomorphism(F, Sb, ab))
const arbFab = lift(fc.constant(ab))
const interchange = fc.property(fc.string(), arbFab, laws.applicative.interchange(F, Sb))
const derivedMap = fc.property(arbFa, laws.applicative.derivedMap(F, Sb, ab))
fc.assert(identity)
fc.assert(homomorphism)
fc.assert(interchange)
fc.assert(derivedMap)
}
}
export const semiring = <a>(S: Semiring</a><a>, E: Eq</a><a>, arb: fc.Arbitrary</a><a>, seed?: number): void => {
const addAssociativity = fc.property(arb, arb, arb, laws.semiring.addAssociativity(S, E))
const addIdentity = fc.property(arb, laws.semiring.addIdentity(S, E))
const commutativity = fc.property(arb, arb, laws.semiring.commutativity(S, E))
const mulAssociativity = fc.property(arb, arb, arb, laws.semiring.mulAssociativity(S, E))
const mulIdentity = fc.property(arb, laws.semiring.mulIdentity(S, E))
const leftDistributivity = fc.property(arb, arb, arb, laws.semiring.leftDistributivity(S, E))
const rightDistributivity = fc.property(arb, arb, arb, laws.semiring.rightDistributivity(S, E))
const annihilation = fc.property(arb, laws.semiring.annihilation(S, E))
fc.assert(addAssociativity, { seed })
fc.assert(addIdentity, { seed })
fc.assert(commutativity, { seed })
fc.assert(mulAssociativity, { seed })
fc.assert(mulIdentity, { seed })
fc.assert(leftDistributivity, { seed })
fc.assert(rightDistributivity, { seed })
fc.assert(annihilation, { seed })
}
</a>
t.notThrows(() => {
fc.assert(inverse);
});
});
testFn(`${label} (with seed=${customParams.seed})`, async t => {
await fc.assert((fc.asyncProperty as any)(...arbitraries, promiseProp), params);
t.pass();
});
}