Added test for rpn 2 degrees and fixed rpn to pass it.

This commit is contained in:
Jeremy Fincher 2003-10-13 04:54:57 +00:00
parent 33cd4aa908
commit f706191201
2 changed files with 5 additions and 1 deletions

View File

@ -166,7 +166,10 @@ class Math(callbacks.Privmsg):
stack = []
for arg in args:
try:
stack.append(complex(arg))
x = complex(arg)
if x == abs(x):
x = abs(x)
stack.append(x)
except ValueError: # Not a float.
if arg in self._mathEnv:
f = self._mathEnv[arg]

View File

@ -49,6 +49,7 @@ class MathTestCase(PluginTestCase, PluginDocumentation):
self.assertResponse('rpn 1 2 3 +', 'Stack: [1, 5]')
self.assertResponse('rpn 1 dup', 'Stack: [1, 1]')
self.assertResponse('rpn 2 3 4 + -', str(2-7))
self.assertNotError('rpn 2 degrees')
def testConvert(self):
self.assertResponse('convert 1 m to cm', '100.0 cm')