'use strict';

const λ = require('fantasy-check/src/adapters/nodeunit');
const {equals} = require('../fantasy-equality');

exports.equality = {
    'when testing the same arrays': λ.check(
        (a) => equals(a, a),
        [λ.arrayOf(λ.AnyVal)]
    ),
    'when testing the same objects': λ.check(
        (a) => equals(a, a),
        [λ.objectLike({
            a: Number,
            b: Object
        })]
    ),
    'when testing the same values': λ.check(
        (a) => equals(a, a),
        [λ.AnyVal]
    ),
    'when testing not null vs null': λ.check(
        (a) => !equals(a, null),
        [λ.AnyVal]
    ),
    'when testing not null vs undefined': λ.check(
        (a) => !equals(a, undefined),
        [λ.AnyVal]
    ),
    'when testing null vs not null': λ.check(
        (a) => !equals(null, a),
Exemple #2
0
    // Monad tests
    'All (Monad)': monad.laws(λ)(Json, run),
    'Left Identity (Monad)': monad.leftIdentity(λ)(Json, run),
    'Right Identity (Monad)': monad.rightIdentity(λ)(Json, run),
    'Associativity (Monad)': monad.associativity(λ)(Json, run),

    // Manual tests
    'when using fromString should be the same as of': λ.check(
        function(a) {
            var x = Json.fromString(JSON.stringify(a)),
                y = Json.of(a);
            return equality.equals(x, y);
        },
        [λ.objectLike({
            a: Number,
            b: Object
        })]
    ),
    'when using readProp to alter value should return correct object': λ.check(
        function(a) {
            var x = Json.of(a.a),
                y = Json.of(a).readProp('a');

            return equality.equals(x.x, y.x);
        },
        [λ.objectLike({
            a: Number,
            b: Object
        })]
    ),
    'when using readProp to alter value should not return correct object': λ.check(