Beispiel #1
0
def test_term_variable_assignment():
    a = Term.from_atom_name('a')
    b = Term.from_atom_name('b')
    eq = Predicate.from_name_arity('=', 2)

    X = Term()
    assert_true(eq(X, a))
    assert_equal(X, a)
    assert_false(eq(X, b))

    assert_true(eq(Term(), b))

    X.put_variable()
    assert_true(eq(X, b))
Beispiel #2
0
def test_term__and__():
    a = Term.from_atom_name('a')
    b = Term.from_atom_name('b')
    eq = Functor('=', 2)

    assert_true((eq(a, a) & eq(b, b))())
    assert_false((eq(a, b) & eq(a, a))())
    assert_false((eq(a, a) & eq(a, b))())

    X = Term()
    Y = Term()
    assert_true((eq(X, a) & eq(Y, a) & eq(X, Y))())
    assert_equal(X, Y)
    X.put_variable()
    Y.put_variable()
    assert_false((eq(X, a) & eq(X, b))())

    assert_equal(str(eq(a, a) & eq(a, b)), 'a=a,a=b')