From f706191201dd343eba532d5beb85ec451077bec4 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Mon, 13 Oct 2003 04:54:57 +0000 Subject: [PATCH] Added test for rpn 2 degrees and fixed rpn to pass it. --- plugins/Math.py | 5 ++++- test/test_Math.py | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/Math.py b/plugins/Math.py index e1f779621..d88e7e44a 100644 --- a/plugins/Math.py +++ b/plugins/Math.py @@ -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] diff --git a/test/test_Math.py b/test/test_Math.py index 24d7ba154..b718f5bbd 100644 --- a/test/test_Math.py +++ b/test/test_Math.py @@ -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')