From c2399ec881634f814efa394fae0a3bc201ff7c8d Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Tue, 14 Sep 2004 21:51:54 +0000 Subject: [PATCH] Case-insensitivity for Math.calc. --- plugins/Math.py | 2 +- test/test_Math.py | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/plugins/Math.py b/plugins/Math.py index 5ed75968c..e46ba1d0c 100644 --- a/plugins/Math.py +++ b/plugins/Math.py @@ -186,7 +186,7 @@ class Math(callbacks.Privmsg): 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. + text = text.lower() def handleMatch(m): s = m.group(1) if s.startswith('0x'): diff --git a/test/test_Math.py b/test/test_Math.py index fa0376767..0afa70d4d 100644 --- a/test/test_Math.py +++ b/test/test_Math.py @@ -112,11 +112,6 @@ class MathTestCase(PluginTestCase, PluginDocumentation): self.assertNotError('calc 3-2*4') 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): self.assertNotRegexp('calc foobar(x)', 'NameError') @@ -126,6 +121,14 @@ class MathTestCase(PluginTestCase, PluginDocumentation): def testCalcFloorWorksWithSqrt(self): 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): self.assertResponse('rpn 5 2 +', '7') self.assertResponse('rpn 1 2 3 +', 'Stack: [1, 5]')