def test_join_between_same_types_results_in_same_value( self, val1: PythonValue, val2: PythonValue) -> None: joined1 = val1.join(val2) joined2 = val2.join(val1) if val1.is_top() or val2.is_top(): assert joined1.is_top() assert joined2.is_top() else: assert joined1.is_top() != isinstance(val1.val, type(val2.val)) assert joined2.is_top() != isinstance(val1.val, type(val2.val)) assert joined1 == joined2
def test_shifts_with_some_values(self, i: PythonValue, j: Optional[int]) -> None: TypeCheckLogger.clean_sing() new_val1 = i.lshift(pv.int(j)) new_val2 = i.rshift(pv.int(j)) assert not i.is_top() assert isinstance(i.val, AbstractValue) assert isinstance(new_val1.val, AbstractValue) assert isinstance(new_val2.val, AbstractValue) if i.val.is_top() or j is None: assert new_val1.val.is_top() assert new_val2.val.is_top() assert len(TypeCheckLogger().warnings) == 0 return if new_val1.val.is_top(): with raises(ValueError): ops.lshift(i.val.val, j) # type: ignore assert len(TypeCheckLogger().warnings) > 0 assert valueError.match(TypeCheckLogger().warnings[0][1]) else: assert ops.lshift(i.val.val, j) == new_val1.val.val # type: ignore if new_val2.val.is_top(): with raises(ValueError): ops.rshift(i.val.val, j) # type: ignore assert len(TypeCheckLogger().warnings) > 0 assert valueError.match(TypeCheckLogger().warnings[-1][1]) else: assert ops.rshift(i.val.val, j) == new_val2.val.val # type: ignore