Added swap to rpn.

This commit is contained in:
Jeremy Fincher 2003-12-02 22:08:46 +00:00
parent 1d54f0ec22
commit 77a8d8bd2d
3 changed files with 6 additions and 0 deletions

View File

@ -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.

View File

@ -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):
"""<rpn math expression>

View File

@ -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')