Fixed bug.

This commit is contained in:
Jeremy Fincher 2004-02-06 07:14:07 +00:00
parent 6c968f4cff
commit 1f312044ae
2 changed files with 7 additions and 5 deletions

View File

@ -88,7 +88,7 @@ class Math(callbacks.Privmsg):
else:
return math.sqrt(x)
_mathEnv['sqrt'] = _sqrt
_mathRe = re.compile(r'((?:(?<![A-Fa-f\d])-)?'
_mathRe = re.compile(r'((?:(?<![A-Fa-f\d)])-)?'
r'(?:0x[A-Fa-f\d]+|'
r'0[0-7]+|'
r'\d+\.\d+|'
@ -140,14 +140,11 @@ class Math(callbacks.Privmsg):
'underscores or brackets in your mathematical '
'expression. Please remove them.')
return
# This removes spaces, too, but we'll leave the removal of _[] for
# safety's sake.
text = text.translate(string.ascii, '_[] \t')
#text = text.translate(string.ascii, '_[] \t')
if 'lambda' in text:
irc.error('You can\'t use lambda in this command.')
return
text = text.replace('lambda', '') # Let's leave it in for safety.
def handleMatch(m):
s = m.group(1)
if s.startswith('0x'):

View File

@ -46,6 +46,11 @@ class MathTestCase(PluginTestCase, PluginDocumentation):
self.assertNotRegexp('calc [9, 5] + [9, 10]', 'TypeError')
self.assertError('calc [9, 5] + [9, 10]')
self.assertNotError('calc degrees(2)')
self.assertNotError('calc (2 * 3) - 2*(3*4)')
self.assertNotError('calc (3) - 2*(3*4)')
self.assertNotError('calc (1600 * 1200) - 2*(1024*1280)')
self.assertNotError('calc 3-2*4')
self.assertNotError('calc (1600 * 1200)-2*(1024*1280)')
def testICalc(self):
self.assertResponse('icalc 1^1', '0')