def test_eq_left_and_right_neq(self): # Arrange. l1 = MockBE(False) r1 = MockBE(False) b1 = BE(l1, r1) l2 = MockBE(False) r2 = MockBE(False) b2 = BE(l1, r1) self.assertEqual(b1 == b2, False)
def test_eq(self): # Arrange. l1 = MockBE(True) r1 = MockBE(True) b1 = BE(l1, r1) l2 = MockBE(True) r2 = MockBE(True) b2 = BE(l1, r1) self.assertEqual(b1 == b2, True)
def test_var_eq(self): # Arrange. l = Idea() r = Idea() b = BE(l, r) v = BE(Idea(), Idea()) e = Idea() # Act. s = b.subst(Idea(), v) # Assert. self.assertEqual(s, e)
def test_var_neq_req(self): # Arrange. l = Idea() r = BE(Idea(), Idea()) b = BE(l, r) e = Idea() # Act. s = b.subst(e, BE(Idea(), Idea())) # Assert. self.assertIsNot(s, b) self.assertIsNot(s.l, l) self.assertIsNot(s.r, r) self.assertEqual(s, BE(Idea(), Idea()))
def test_neq_different_types(self): # Arrange. l1 = MockBE(True) r1 = MockBE(True) b1 = BE(l1, r1) b2 = MockBE(True) self.assertEqual(b1 == b2, False)
def test_str(self): # Arrange. b = BE(I(), I()) # Act. s = str(b) # Assert. self.assertEqual(s, "(IBEI)")
def test_repr(self): # Arrange. l = MockBE(True, "L") r = MockBE(True, "R") b = BE(l, r) expected = "BE(L,R)" # Assert. self.assertEqual(repr(b), expected)
def test_repr_check(self): # Arrange. b = BE(I(), I()) # Act. r = repr(b) e = eval(r) # Assert. self.assertEqual(r, "BE(I(),I())") self.assertEqual(e, b)
def test_eq_is_reflexive(self): # Arrange. b = BE(Idea(), Idea()) # Act & Assert. self.assertEqual(b == b, True)