Added abs to the calc command.

This commit is contained in:
Jeremy Fincher 2004-09-06 08:07:54 +00:00
parent b133e59af4
commit f4f25ef72c
2 changed files with 7 additions and 0 deletions

View File

@ -129,6 +129,7 @@ class Math(callbacks.Privmsg):
else: else:
return math.sqrt(x) return math.sqrt(x)
_mathEnv['sqrt'] = _sqrt _mathEnv['sqrt'] = _sqrt
_mathEnv['abs'] = abs
_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]+|'

View File

@ -175,6 +175,12 @@ class MathTestCase(PluginTestCase, PluginDocumentation):
self.assertNotError('units mass') self.assertNotError('units mass')
self.assertNotError('units flux density') self.assertNotError('units flux density')
def testAbs(self):
self.assertResponse('calc abs(2)', '2')
self.assertResponse('calc abs(-2)', '2')
self.assertResponse('calc abs(2.0)', '2')
self.assertResponse('calc abs(-2.0)', '2')
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: