def test_sub(self): vars1 = Variables([x, y]) vars2 = Variables([y, z]) vars3 = vars1 - vars2 # [x] self.assertEqual(vars3, Variables([x])) vars4 = vars1 - y # [x] self.assertEqual(vars4, Variables([x]))
def test_add(self): vars1 = Variables([x, y]) vars2 = Variables([y, z]) vars3 = vars1 + vars2 # [x, y, z] self.assertEqual(vars3.size(), 3) vars4 = vars1 + z # [x, y, z] self.assertEqual(vars4.size(), 3) vars5 = x + vars1 # [x, y] self.assertEqual(vars5.size(), 2)
def test_iter(self): vars = Variables([x, y, z]) count = 0 for var in vars: self.assertTrue(var in vars) count = count + 1 self.assertEqual(count, len(vars))
def test_subset_properties(self): vars1 = Variables([x, y, z]) vars2 = Variables([x, y]) self.assertFalse(vars1.IsSubsetOf(vars2)) self.assertFalse(vars1.IsStrictSubsetOf(vars2)) self.assertTrue(vars1.IsSupersetOf(vars2)) self.assertTrue(vars1.IsStrictSupersetOf(vars2))
def test_eq(self): vars1 = Variables([x, y, z]) vars2 = Variables([x, y]) self.assertFalse(vars1 == vars2)
def test_sub_assignment(self): vars = Variables([x, y, z]) vars -= y # = [x, z] self.assertEqual(vars, Variables([x, z])) vars -= Variables([x]) # = [z] self.assertEqual(vars, Variables([z]))
def test_intersect(self): vars1 = Variables([x, y, z]) vars2 = Variables([y, w]) vars3 = intersect(vars1, vars2) # = [y] self.assertEqual(vars3, Variables([y]))
def test_add_assignment(self): vars = Variables([x]) vars += y self.assertEqual(vars.size(), 2) vars += Variables([x, z]) self.assertEqual(vars.size(), 3)
def test_to_string(self): vars = Variables([x, y, z]) self.assertEqual(vars.to_string(), "{x, y, z}") self.assertEqual("{}".format(vars), "{x, y, z}")
def test_lt(self): vars1 = Variables([x, y]) vars2 = Variables([x, y, z]) self.assertTrue(vars1 < vars2)
def test_repr(self): vars = Variables([x, y, z]) self.assertEqual(repr(vars), '<Variables "{x, y, z}">')
def test_get_free_variables(self): f = x > y self.assertEqual(f.GetFreeVariables(), Variables([x, y]))
def test_constructor_list(self): vars = Variables([x, y, z]) self.assertEqual(vars.size(), 3) self.assertEqual(len(vars), 3)
def test_include(self): vars = Variables([x, y, z]) self.assertTrue(vars.include(y)) self.assertTrue(y in vars) self.assertFalse(w in vars)
def test_erase2(self): vars1 = Variables([x, y, z]) vars2 = Variables([w, z]) count = vars1.erase(vars2) self.assertEqual(count, 1) self.assertEqual(vars1.size(), 2)
def test_erase1(self): vars = Variables([x, y, z]) count = vars.erase(x) self.assertEqual(count, 1)
def test_insert2(self): vars = Variables([x]) vars.insert(Variables([y, z])) self.assertEqual(vars.size(), 3)
def test_insert1(self): vars = Variables() vars.insert(x) self.assertEqual(vars.size(), 1)
def test_forall(self): self.assertEqual(str(forall(Variables([x, y, z]), x == 0)), "forall({x}. (x == 0))") self.assertEqual(str(forall([x, y, z], x == 0)), "forall({x}. (x == 0))")
def test_default_constructor(self): vars = Variables() self.assertEqual(vars.size(), 0) self.assertTrue(vars.empty())