Exemplo n.º 1
0
def test_equal_symmetric(x, y):
    hypothesis.assume(x is not y)
    equal_xy = simplify(lib.equal(x, y))
    equal_yx = simplify(lib.equal(y, x))
    hypothesis.assume(equal_xy in bool_values)
    hypothesis.assume(equal_yx in bool_values)
    assert equal_xy is equal_yx
Exemplo n.º 2
0
def test_equal_transitive(x, y, z):
    # hypothesis.assume(x is not y and x is not z and y is not z)
    equal_xy = simplify(lib.equal(x, y))
    hypothesis.assume(equal_xy in bool_values)
    equal_yz = simplify(lib.equal(y, z))
    hypothesis.assume(equal_yz in bool_values)
    equal_xz = simplify(lib.equal(x, z))
    hypothesis.assume(equal_xz in bool_values)
    if equal_xy is true and equal_yz is true:
        assert equal_xz is true
    if equal_xz is false:
        assert equal_xy is false or equal_yz is false
Exemplo n.º 3
0
def test_less_antisymmetric(x, y):
    less_xy = simplify(lib.less(x, y))
    less_yx = simplify(lib.less(y, x))
    equal_xy = simplify(lib.equal(x, y))
    print('LESS: {}, NLESS: {}, EQUAL: {}'.format(less_xy, less_yx, equal_xy))
    if less_xy is true and less_yx is true:
        assert equal_xy is true
    if equal_xy is false:
        assert less_xy is false or less_yx is false
Exemplo n.º 4
0
def test_less_antisymmetric(x, y):
    hypothesis.assume(x is not y)
    less_xy = simplify(lib.less(x, y))
    less_yx = simplify(lib.less(y, x))
    equal_xy = simplify(lib.equal(x, y))
    hypothesis.assume(less_xy in bool_values)
    hypothesis.assume(less_yx in bool_values)
    if less_xy is true and less_yx is true:
        assert equal_xy is true
    if equal_xy is false:
        assert less_xy is not true or less_yx is not true
Exemplo n.º 5
0
def test_equal_reflexive(x):
    equal_xx = simplify(lib.equal(x, x))
    assert equal_xx == true
Exemplo n.º 6
0
def test_equal(x, y, expected):
    assert simplify(lib.equal(x, y)) == expected
Exemplo n.º 7
0
        (S, error),
    ]
)
def test_boool_constructed(x, expected):
    assert simplify(app(a_boool, x)) == expected


# ----------------------------------------------------------------------------
# Scott ordering

bool_values = (error, undefined, true, false)


@for_each(
    [
        (x, y, lib.equal(x, y)),
        (quote(x), quote(x), true),
        (quote(undefined), quote(error), false),
        (quote(error), quote(undefined), false),
        (error, x, error),
        (x, error, error),
        (undefined, x, lib.equal(undefined, x)),
        (x, undefined, lib.equal(x, undefined)),
        (undefined, quote(x), undefined),
        (quote(x), undefined, undefined),
        (quote(error), quote(error), true),
        (quote(undefined), quote(undefined), true),
        (quote(num(0)), quote(num(0)), true),
        (quote(num(1)), quote(num(1)), true),
        (quote(num(2)), quote(num(2)), true),
        (quote(num(3)), quote(num(3)), true),