diff --git a/ChangeLog b/ChangeLog index 1002c1b9b..6736a6ce8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,5 @@ + * Added a swap function to Math.rpn. + * Changed the logging infrastructure significantly; each plugin now has its own logger (and thus logfile), in addition to being logged in the main logfile. diff --git a/plugins/Math.py b/plugins/Math.py index 96eef40e3..ca0732b97 100644 --- a/plugins/Math.py +++ b/plugins/Math.py @@ -151,6 +151,7 @@ class Math(callbacks.Privmsg): _rpnEnv = { 'dup': lambda s: s.extend([s.pop()]*2), + 'swap': lambda s: s.extend([s.pop(), s.pop()]) } def rpn(self, irc, msg, args): """ diff --git a/test/test_Math.py b/test/test_Math.py index ad5d5b9a1..e49b23328 100644 --- a/test/test_Math.py +++ b/test/test_Math.py @@ -60,6 +60,9 @@ class MathTestCase(PluginTestCase, PluginDocumentation): self.assertResponse('rpn 2 3 4 + -', str(2-7)) self.assertNotError('rpn 2 degrees') + def testRpnSwap(self): + self.assertResponse('rpn 1 2 swap', 'Stack: [2, 1]') + def testRpmNoSyntaxError(self): self.assertNotRegexp('rpn 2 3 foobar', 'SyntaxError')