Fixed bug #802801 about calc exposing too ugly error messages. Added tests.

This commit is contained in:
Jeremy Fincher 2003-09-09 08:25:33 +00:00
parent 9bca5d98f7
commit d68c42684d
2 changed files with 6 additions and 2 deletions

View File

@ -560,9 +560,11 @@ class FunCommands(callbacks.Privmsg):
x = complex(eval(text, self._mathEnv, self._mathEnv))
irc.reply(msg, self._complexToString(x))
except OverflowError:
irc.reply(msg, 'Go get scanez, this is a *real* math problem!')
irc.error(msg, 'Go get scanez, this is a *real* math problem!')
except TypeError:
irc.error(msg, 'Something in there wasn\'t a valid number.')
except Exception, e:
irc.reply(msg, debug.exnToString(e))
irc.error(msg, debug.exnToString(e))
_rpnEnv = {
'dup': lambda s: s.extend([s.pop()]*2),

View File

@ -61,6 +61,8 @@ class FunCommandsTest(PluginTestCase, PluginDocumentation):
self.assertResponse('calc e**(i*pi)+1', '0')
self.assertResponse('calc (-5)**.5', '2.2360679775i')
self.assertResponse('calc -((-5)**.5)', '-2.2360679775i')
self.assertNotRegexp('calc [9, 5] + [9, 10]', 'TypeError')
self.assertError('calc [9, 5] + [9, 10]')
def testChr(self):
for i in range(256):