def test_create_var_prefix(self):
     # Arrange
     ctx = SolverContext(z3.Context())
     prefix = 'CustPrefix'
     # Act
     var = ctx.create_fresh_var(z3.IntSort(), value=10, name_prefix=prefix)
     # Assert
     self.assertTrue(isinstance(var, SMTVar))
     self.assertTrue(var.name.startswith(prefix))
 def test_set_model(self):
     # Arrange
     values = ['A', 'B', 'C']
     sort_name = 'TestType'
     ctx = SolverContext(z3.Context())
     vsort = ctx.create_enum_type(sort_name, values)
     var1 = ctx.create_fresh_var(vsort)
     val1 = vsort.get_symbolic_value('A')
     var2 = ctx.create_fresh_var(z3.IntSort(ctx=ctx.z3_ctx))
     var3 = ctx.create_fresh_var(z3.BoolSort(ctx=ctx.z3_ctx))
     solver = z3.Solver(ctx=ctx.z3_ctx)
     solver.add(var1.var == val1)
     solver.add(var2.var == 10)
     solver.add(var3.var == True)
     solver.check()
     # Act
     ctx.set_model(solver.model())
     # Assert
     self.assertTrue(var1.is_concrete)
     self.assertTrue(var2.is_concrete)
     self.assertTrue(var3.is_concrete)
     self.assertEquals(var1.get_value(), 'A')
     self.assertEquals(var2.get_value(), 10)
     self.assertEquals(var3.get_value(), True)
 def test_create_var(self):
     ctx = SolverContext(z3.Context())
     var = ctx.create_fresh_var(z3.IntSort(), value=10)
     self.assertTrue(isinstance(var, SMTVar))
     with self.assertRaises(ValueError):
         var = ctx.create_fresh_var(z3.IntSort(), name=var.name, value=10)