mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-26 03:54:08 +01:00
Fixed bug.
This commit is contained in:
parent
6c968f4cff
commit
1f312044ae
@ -88,7 +88,7 @@ class Math(callbacks.Privmsg):
|
|||||||
else:
|
else:
|
||||||
return math.sqrt(x)
|
return math.sqrt(x)
|
||||||
_mathEnv['sqrt'] = _sqrt
|
_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'(?:0x[A-Fa-f\d]+|'
|
||||||
r'0[0-7]+|'
|
r'0[0-7]+|'
|
||||||
r'\d+\.\d+|'
|
r'\d+\.\d+|'
|
||||||
@ -140,14 +140,11 @@ class Math(callbacks.Privmsg):
|
|||||||
'underscores or brackets in your mathematical '
|
'underscores or brackets in your mathematical '
|
||||||
'expression. Please remove them.')
|
'expression. Please remove them.')
|
||||||
return
|
return
|
||||||
# This removes spaces, too, but we'll leave the removal of _[] for
|
#text = text.translate(string.ascii, '_[] \t')
|
||||||
# safety's sake.
|
|
||||||
text = text.translate(string.ascii, '_[] \t')
|
|
||||||
if 'lambda' in text:
|
if 'lambda' in text:
|
||||||
irc.error('You can\'t use lambda in this command.')
|
irc.error('You can\'t use lambda in this command.')
|
||||||
return
|
return
|
||||||
text = text.replace('lambda', '') # Let's leave it in for safety.
|
text = text.replace('lambda', '') # Let's leave it in for safety.
|
||||||
|
|
||||||
def handleMatch(m):
|
def handleMatch(m):
|
||||||
s = m.group(1)
|
s = m.group(1)
|
||||||
if s.startswith('0x'):
|
if s.startswith('0x'):
|
||||||
|
@ -46,6 +46,11 @@ class MathTestCase(PluginTestCase, PluginDocumentation):
|
|||||||
self.assertNotRegexp('calc [9, 5] + [9, 10]', 'TypeError')
|
self.assertNotRegexp('calc [9, 5] + [9, 10]', 'TypeError')
|
||||||
self.assertError('calc [9, 5] + [9, 10]')
|
self.assertError('calc [9, 5] + [9, 10]')
|
||||||
self.assertNotError('calc degrees(2)')
|
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):
|
def testICalc(self):
|
||||||
self.assertResponse('icalc 1^1', '0')
|
self.assertResponse('icalc 1^1', '0')
|
||||||
|
Loading…
Reference in New Issue
Block a user