Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
    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])
Ejemplo n.º 3
0
 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)
Ejemplo n.º 4
0
 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
Ejemplo n.º 5
0
 def test_uncallable_fun_raises(self):
     uncallable = 5
     with raises(StrictTypeError, 'is not callable'):
         arrow(uncallable, A, A)
Ejemplo n.º 6
0
 def test_less_than_two_types_raises(self, types):
     with raises(TypeError, 'Needs at least two types:'):
         args = [int] + types
         arrow(*args)