def test___add__():
    """Test + operator for AssumptionBase object."""
    ahead_rs = RelationSymbol('Ahead', 4)
    behind_rs = RelationSymbol('Behind', 4)
    pm_rs = RelationSymbol('PM', 1)
    am_rs = RelationSymbol('AM', 1)
    test_rs = RelationSymbol('test', 1)
    vocabulary = Vocabulary(
        ['C1', 'C2'],
        [ahead_rs, behind_rs, am_rs, pm_rs, test_rs],
        ['V1', 'V2'])

    f1 = Formula(vocabulary, 'Ahead', 'C1', 'V1')
    f2 = Formula(vocabulary, 'Behind', 'C1', 'V1')
    f3 = Formula(vocabulary, 'PM', 'C1')
    f4 = Formula(vocabulary, 'AM', 'C1')
    a_empty = AssumptionBase(vocabulary)
    a_1 = AssumptionBase(f1)
    a_2 = AssumptionBase(f2)
    a_3 = AssumptionBase(f3)
    a_1_2 = AssumptionBase(f1, f2)
    a_1_2_3 = AssumptionBase(f1, f2, f3)
    a_1_2_3_4 = AssumptionBase(f1, f2, f3, f4)

    assert a_1 == a_empty + f1
    assert a_1 == f1 + a_empty
    assert a_1 == a_empty + a_1
    assert a_1 == a_1 + a_empty
    assert a_1_2 == a_1 + f2
    assert a_1_2 == f2 + a_1
    assert a_1_2 is not a_1
    assert a_1_2 is not f2
    ref_a = a_1 + f2
    f2._name = "test"
    assert ref_a[-1]._name != f2._name
    assert a_1_2 == a_1 + a_2
    assert a_1_2_3 == a_1 + a_2 + a_3
    assert a_1_2_3 == a_1 + f2 + f3
    assert a_1_2_3_4 == a_1 + f2 + f3 + f4

    assert f1._vocabulary is f2._vocabulary is f3._vocabulary is \
        f4._vocabulary is a_1._vocabulary is a_2._vocabulary is \
        a_3._vocabulary is a_1_2._vocabulary is a_1_2_3._vocabulary is \
        a_1_2_3_4._vocabulary is a_empty._vocabulary
示例#2
0
def test___deepcopy__():
    """Test Test copy.deepcopy for Formula object."""
    ahead_rs = RelationSymbol('Ahead', 4)
    behind_rs = RelationSymbol('Behind', 4)
    pm_rs = RelationSymbol('PM', 1)
    vocabulary = Vocabulary(['C1', 'C2'], [ahead_rs, behind_rs, pm_rs], ['V1', 'V2'])

    f = Formula(vocabulary, 'Ahead', 'C1', 'V1')

    from copy import deepcopy
    f_copy = deepcopy(f)

    assert f == f_copy
    assert f is not f_copy
    assert f._vocabulary is f_copy._vocabulary
    assert f._terms is not f_copy._terms

    f._name = "F"
    assert f._name != f_copy._name
示例#3
0
def test___deepcopy__():
    """Test Test copy.deepcopy for Formula object."""
    ahead_rs = RelationSymbol('Ahead', 4)
    behind_rs = RelationSymbol('Behind', 4)
    pm_rs = RelationSymbol('PM', 1)
    vocabulary = Vocabulary(['C1', 'C2'], [ahead_rs, behind_rs, pm_rs],
                            ['V1', 'V2'])

    f = Formula(vocabulary, 'Ahead', 'C1', 'V1')

    from copy import deepcopy
    f_copy = deepcopy(f)

    assert f == f_copy
    assert f is not f_copy
    assert f._vocabulary is f_copy._vocabulary
    assert f._terms is not f_copy._terms

    f._name = "F"
    assert f._name != f_copy._name