-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtests.py
More file actions
32 lines (24 loc) · 1.22 KB
/
tests.py
File metadata and controls
32 lines (24 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import copy
from forseti.formula import Symbol, Or, And, Not
from nose import runmodule
from nose.tools import assert_equal, assert_true
import util
from extra_formulas import GeneralizedAnd, GeneralizedOr
def test_helper():
statement = Or(Or(Symbol("B"), Symbol("C")), Symbol("A"))
new_statement, change = util.flatten(copy.deepcopy(statement))
assert_equal(new_statement, GeneralizedOr(Symbol("B"), Symbol("C"), Symbol("A")))
assert_true(change)
def test_helper2():
statement = GeneralizedOr(Symbol("a"), Symbol("a"))
# need to manually set it to this as otherwise the constructor would flatten it automatically
statement.args[0] = Or(And(Symbol("b"), Not(Symbol("c"))), And(Symbol("c"), Not(Symbol("b"))))
new_statement, change = util.flatten(copy.deepcopy(statement))
assert_equal(new_statement, GeneralizedOr(Symbol("a"), And(Symbol("b"), Not(Symbol("c"))),
And(Symbol("c"), Not(Symbol("b")))))
assert_true(change)
def test_generalized_or_constructor():
statement = GeneralizedOr(Or(Symbol("B"), Symbol("C")), Symbol("A"))
assert_equal(statement, GeneralizedOr(Symbol("B"), Symbol("C"), Symbol("A")))
if __name__ == "__main__":
runmodule()