def test_mismatching_typevariables_raises(self): with raises(StrictTypeError, 'Expected argument'): asum = arrow(self.add, A, A, A) asum(3, 4.0) # <- both should be of the same type with raises(StrictTypeError, 'Expected argument'): afloat = arrow(float, A, A) # <- should return float afloat(1)
def test_wrong_arg_types_raises(self, length): arglist = [Bool, Int, Real] misfits = [4, 0.7, 1 + 1j] with raises(StrictTypeError, 'is of wrong type for signature'): t = arrow(*[self.argcount] + arglist[:length] + [Int]) t(*misfits[:length])
def test_wrong_return_type_raises(self): with raises(StrictTypeError, 'is of wrong type for signature'): t = arrow(self.argcount, A, Bool) # <- bool should be Int t(1)
def test_wrong_arg_count_raises(self): with raises(StrictTypeError, 'Wrong number of arguments in'): t = arrow(self.no, A, Bool) t('one', 'extra') # <-- Expects only one argument
def test_uncallable_fun_raises(self): uncallable = 5 with raises(StrictTypeError, 'is not callable'): arrow(uncallable, A, A)
def test_less_than_two_types_raises(self, types): with raises(TypeError, 'Needs at least two types:'): args = [int] + types arrow(*args)