File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed
Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,9 @@ def __iter__(self):
7878 def __hash__ (self ):
7979 return hash (self ._terms )
8080
81+ def __len__ (self ):
82+ return len (self ._terms )
83+
8184 def __eq__ (self , other ):
8285 return (isinstance (other , self .__class__ ) and
8386 self ._terms == other ._terms )
Original file line number Diff line number Diff line change @@ -62,6 +62,16 @@ def test_variable_hash(self):
6262 self .assertEqual (hash (Variable ('xyz' )), hash (Variable ('xyz' )))
6363
6464
65+ class TestTerm (unittest .TestCase ):
66+ def test_length_of_and (self ):
67+ term = And (Variable ('b1' ), Variable ('b2' ))
68+ self .assertEqual (len (term ), 2 )
69+
70+ def test_length_of_or (self ):
71+ term = Or (Variable ('b1' ), And (Variable ('b2' ), Variable ('b3' )))
72+ self .assertEqual (len (term ), 2 )
73+
74+
6575class TestExpression (unittest .TestCase ):
6676 def test_expression_substitute_existing (self ):
6777 e = Expression ('b1' )
You can’t perform that action at this time.
0 commit comments