mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 11:09:23 +01:00
Case-insensitivity for Math.calc.
This commit is contained in:
parent
001d8439c3
commit
c2399ec881
@ -186,7 +186,7 @@ class Math(callbacks.Privmsg):
|
|||||||
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.lower()
|
||||||
def handleMatch(m):
|
def handleMatch(m):
|
||||||
s = m.group(1)
|
s = m.group(1)
|
||||||
if s.startswith('0x'):
|
if s.startswith('0x'):
|
||||||
|
@ -112,11 +112,6 @@ class MathTestCase(PluginTestCase, PluginDocumentation):
|
|||||||
self.assertNotError('calc 3-2*4')
|
self.assertNotError('calc 3-2*4')
|
||||||
self.assertNotError('calc (1600 * 1200)-2*(1024*1280)')
|
self.assertNotError('calc (1600 * 1200)-2*(1024*1280)')
|
||||||
|
|
||||||
def testICalc(self):
|
|
||||||
self.assertResponse('icalc 1^1', '0')
|
|
||||||
self.assertResponse('icalc 10**24', '1' + '0'*24)
|
|
||||||
self.assertRegexp('icalc 49/6', '8.16')
|
|
||||||
|
|
||||||
def testCalcNoNameError(self):
|
def testCalcNoNameError(self):
|
||||||
self.assertNotRegexp('calc foobar(x)', 'NameError')
|
self.assertNotRegexp('calc foobar(x)', 'NameError')
|
||||||
|
|
||||||
@ -126,6 +121,14 @@ class MathTestCase(PluginTestCase, PluginDocumentation):
|
|||||||
def testCalcFloorWorksWithSqrt(self):
|
def testCalcFloorWorksWithSqrt(self):
|
||||||
self.assertNotError('calc floor(sqrt(5))')
|
self.assertNotError('calc floor(sqrt(5))')
|
||||||
|
|
||||||
|
def testCaseInsensitive(self):
|
||||||
|
self.assertNotError('calc PI**PI')
|
||||||
|
|
||||||
|
def testICalc(self):
|
||||||
|
self.assertResponse('icalc 1^1', '0')
|
||||||
|
self.assertResponse('icalc 10**24', '1' + '0'*24)
|
||||||
|
self.assertRegexp('icalc 49/6', '8.16')
|
||||||
|
|
||||||
def testRpn(self):
|
def testRpn(self):
|
||||||
self.assertResponse('rpn 5 2 +', '7')
|
self.assertResponse('rpn 5 2 +', '7')
|
||||||
self.assertResponse('rpn 1 2 3 +', 'Stack: [1, 5]')
|
self.assertResponse('rpn 1 2 3 +', 'Stack: [1, 5]')
|
||||||
|
Loading…
Reference in New Issue
Block a user