示例#1
0
 def testNoOverloads(self):
     self.assertEqual(callables_mod.f1(), None)
     self.assertEqual(callables_mod.f2(2), 2+3)
     self.assertEqual(callables_mod.f2(a=3), 3+3)
     self.assertEqual(callables_mod.f3(4, 5), 20.0)
     self.assertEqual(callables_mod.f3(6, b=7), 6.0*7)
     self.assertEqual(callables_mod.f3(a=8, b=9), 8.0*9)
示例#2
0
 def testOverload(self):
     # these should be disambiguated just by the number of arguments
     self.assertEqual(callables_mod.f(), callables_mod.f1())
     self.assertEqual(callables_mod.f(2), callables_mod.f2(2))
     self.assertEqual(callables_mod.f(a=3), callables_mod.f2(a=3))
     # these should be disambiguated by the keyword argument names
     self.assertEqual(callables_mod.f(a=8, b=9), callables_mod.f3(a=8, b=9))
     self.assertEqual(callables_mod.f(c=8, b=9), callables_mod.f4(c=8, b=9))
     # this should be ambiguous
     self.assertRaises(bp3.OverloadResolutionError, callables_mod.f, 4, 5)
     self.assertRaises(bp3.OverloadResolutionError, callables_mod.f, 5, b=4)