def test_isinstance(self): with StateSpaceContext(SimpleStateSpace()): f = SmtFloat("f") self.assertFalse(isinstance(f, float)) self.assertFalse(isinstance(f, int)) self.assertTrue(_isinstance(f, float)) self.assertFalse(_isinstance(f, int))
def test_isfinite(self): space = SimpleStateSpace() with Patched(), StateSpaceContext(space): x = SymbolicFloat("symfloat") self.assertTrue(math.isfinite(x)) self.assertTrue(math.isfinite(2.3)) self.assertFalse(math.isfinite(float("nan")))
def test_isfinite(self): space = SimpleStateSpace() with Patched(enabled=lambda: True), StateSpaceContext(space): x = SmtFloat('symfloat') self.assertTrue(math.isfinite(x)) self.assertTrue(math.isfinite(2.3)) self.assertFalse(math.isfinite(float('nan')))
def test_copy(self) -> None: poke1 = make_fake_object(SimpleStateSpace(), Pokeable, 'ppoke') poke1.poke() poke2 = copy.copy(poke1) self.assertIsNot(poke1, poke2) self.assertEqual(type(poke1), type(poke2)) self.assertIs(poke1.x, poke2.x) poke1.poke() self.assertIsNot(poke1.x, poke2.x) self.assertNotEqual(str(poke1.x.var), str(poke2.x.var))
def test_copy(self): with StateSpaceContext(SimpleStateSpace()): poke1 = proxy_class_as_masquerade(Pokeable, "ppoke") poke1.poke() poke2 = copy.copy(poke1) self.assertIsNot(poke1, poke2) self.assertEqual(type(poke1), type(poke2)) self.assertIs(poke1.x, poke2.x) poke1.poke() self.assertIsNot(poke1.x, poke2.x) self.assertNotEqual(str(poke1.x.var), str(poke2.x.var))
def test_isinstance(self): f = SmtFloat(SimpleStateSpace(), float, 'f') self.assertFalse(isinstance(f, float)) self.assertFalse(isinstance(f, int)) self.assertTrue(_isinstance(f, float)) self.assertFalse(_isinstance(f, int))
def setUp(self): self.space_ctx_ = StateSpaceContext(SimpleStateSpace()) self.space_ctx_.__enter__()
def test_proxy_type(self) -> None: with StateSpaceContext(SimpleStateSpace()): poke = proxy_class_as_masquerade(Pokeable, "ppoke") self.assertIs(type(poke), Pokeable)
def test_proxy_type(self) -> None: with StateSpaceContext(SimpleStateSpace()): poke = make_fake_object(Pokeable, 'ppoke') self.assertIs(type(poke), Pokeable)
def test_smtfloat_like_a_float(self): with StateSpaceContext(SimpleStateSpace()): self.assertEqual(type(SymbolicFloat(12)), float) self.assertEqual(SymbolicFloat(12), 12.0)