mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-30 14:14:37 +01:00
Added swap to rpn.
This commit is contained in:
parent
1d54f0ec22
commit
77a8d8bd2d
@ -1,3 +1,5 @@
|
|||||||
|
* Added a swap function to Math.rpn.
|
||||||
|
|
||||||
* Changed the logging infrastructure significantly; each plugin
|
* Changed the logging infrastructure significantly; each plugin
|
||||||
now has its own logger (and thus logfile), in addition to being
|
now has its own logger (and thus logfile), in addition to being
|
||||||
logged in the main logfile.
|
logged in the main logfile.
|
||||||
|
@ -151,6 +151,7 @@ class Math(callbacks.Privmsg):
|
|||||||
|
|
||||||
_rpnEnv = {
|
_rpnEnv = {
|
||||||
'dup': lambda s: s.extend([s.pop()]*2),
|
'dup': lambda s: s.extend([s.pop()]*2),
|
||||||
|
'swap': lambda s: s.extend([s.pop(), s.pop()])
|
||||||
}
|
}
|
||||||
def rpn(self, irc, msg, args):
|
def rpn(self, irc, msg, args):
|
||||||
"""<rpn math expression>
|
"""<rpn math expression>
|
||||||
|
@ -60,6 +60,9 @@ class MathTestCase(PluginTestCase, PluginDocumentation):
|
|||||||
self.assertResponse('rpn 2 3 4 + -', str(2-7))
|
self.assertResponse('rpn 2 3 4 + -', str(2-7))
|
||||||
self.assertNotError('rpn 2 degrees')
|
self.assertNotError('rpn 2 degrees')
|
||||||
|
|
||||||
|
def testRpnSwap(self):
|
||||||
|
self.assertResponse('rpn 1 2 swap', 'Stack: [2, 1]')
|
||||||
|
|
||||||
def testRpmNoSyntaxError(self):
|
def testRpmNoSyntaxError(self):
|
||||||
self.assertNotRegexp('rpn 2 3 foobar', 'SyntaxError')
|
self.assertNotRegexp('rpn 2 3 foobar', 'SyntaxError')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user