mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-11 12:42:34 +01:00
Fixed bug #802801 about calc exposing too ugly error messages. Added tests.
This commit is contained in:
parent
9bca5d98f7
commit
d68c42684d
@ -560,9 +560,11 @@ class FunCommands(callbacks.Privmsg):
|
|||||||
x = complex(eval(text, self._mathEnv, self._mathEnv))
|
x = complex(eval(text, self._mathEnv, self._mathEnv))
|
||||||
irc.reply(msg, self._complexToString(x))
|
irc.reply(msg, self._complexToString(x))
|
||||||
except OverflowError:
|
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:
|
except Exception, e:
|
||||||
irc.reply(msg, debug.exnToString(e))
|
irc.error(msg, debug.exnToString(e))
|
||||||
|
|
||||||
_rpnEnv = {
|
_rpnEnv = {
|
||||||
'dup': lambda s: s.extend([s.pop()]*2),
|
'dup': lambda s: s.extend([s.pop()]*2),
|
||||||
|
@ -61,6 +61,8 @@ class FunCommandsTest(PluginTestCase, PluginDocumentation):
|
|||||||
self.assertResponse('calc e**(i*pi)+1', '0')
|
self.assertResponse('calc e**(i*pi)+1', '0')
|
||||||
self.assertResponse('calc (-5)**.5', '2.2360679775i')
|
self.assertResponse('calc (-5)**.5', '2.2360679775i')
|
||||||
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):
|
def testChr(self):
|
||||||
for i in range(256):
|
for i in range(256):
|
||||||
|
Loading…
Reference in New Issue
Block a user