Example #1
0
    'Homomorphism (Applicative)': applicative.homomorphism(λ)(Seq, run),
    'Interchange (Applicative)': applicative.interchange(λ)(Seq, run),

    // Functor tests
    'All (Functor)': functor.laws(λ)(Seq.of, run),
    'Identity (Functor)': functor.identity(λ)(Seq.of, run),
    'Composition (Functor)': functor.composition(λ)(Seq.of, run),

    // Monad tests
    'All (Monad)': monad.laws(λ)(Seq, run),
    'Left Identity (Monad)': monad.leftIdentity(λ)(Seq, run),
    'Right Identity (Monad)': monad.rightIdentity(λ)(Seq, run),
    'Associativity (Monad)': monad.associativity(λ)(Seq, run),

    // Monoid tests
    'All (Monoid)': monoid.laws(λ)(Seq, run),
    'leftIdentity (Monoid)': monoid.leftIdentity(λ)(Seq, run),
    'rightIdentity (Monoid)': monoid.rightIdentity(λ)(Seq, run),
    'associativity (Monoid)': monoid.associativity(λ)(Seq, run),

    // Semigroup tests
    'All (Semigroup)': semigroup.laws(λ)(Seq.of, run),
    'associativity (Semigroup)': semigroup.associativity(λ)(Seq.of, run),

    // Manual tests
    'when using concat should concat in correct order': λ.check(
        function(a, b) {
            var x = Seq.fromArray(a),
                y = Seq.fromArray(b);

            return λ.equals(x.concat(y), Seq.fromArray(a.concat(b)));
Example #2
0
    'Homomorphism (Applicative)': applicative.homomorphism(λ)(Ratio, run),
    'Interchange (Applicative)': applicative.interchange(λ)(Ratio, run),

    // Functor tests
    'All (Functor)': functor.laws(λ)(Ratio.of, run),
    'Identity (Functor)': functor.identity(λ)(Ratio.of, run),
    'Composition (Functor)': functor.composition(λ)(Ratio.of, run),

    // Monad tests
    'All (Monad)': monad.laws(λ)(Ratio, run),
    'Left Identity (Monad)': monad.leftIdentity(λ)(Ratio, run),
    'Right Identity (Monad)': monad.rightIdentity(λ)(Ratio, run),
    'Associativity (Monad)': monad.associativity(λ)(Ratio, run),

    // Monoid tests
    'All (Monoid)': monoid.laws(λ)(Ratio, run),
    'leftIdentity (Monoid)': monoid.leftIdentity(λ)(Ratio, run),
    'rightIdentity (Monoid)': monoid.rightIdentity(λ)(Ratio, run),
    'associativity (Monoid)': monoid.associativity(λ)(Ratio, run),

    // Manual tests
    'when testing add should return correct value': function(test) {
        var x = Ratio.of(0.6).add(Ratio.of(0.2));
        test.ok(equals(x, Ratio.of(0.8)));
        test.done();
    },
    'when testing add with simplify should return correct value': function(test) {
        var x = Ratio(0.6, 0.8).add(Ratio.of(0.2));
        test.ok(equals(x.simplify(), Ratio(4278419646001971, 4503599627370496)));
        test.done();
    },