mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-24 03:33:11 +01:00
Fixed bug.
This commit is contained in:
parent
6c968f4cff
commit
1f312044ae
@ -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'):
|
||||
|
@ -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')
|
||||
|
Loading…
Reference in New Issue
Block a user