mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-23 10:34:19 +01:00
wrap() String.len to vastly simplify the function and prevent responding with -1 when we get no arguments.
Add a test to make sure we respond with the help when called with no arguments.
This commit is contained in:
parent
99696986f6
commit
068f029355
@ -108,16 +108,13 @@ class String(callbacks.Plugin):
|
|||||||
irc.reply(utils.str.soundex(text, length))
|
irc.reply(utils.str.soundex(text, length))
|
||||||
soundex = wrap(soundex, ['somethingWithoutSpaces', additional('int', 4)])
|
soundex = wrap(soundex, ['somethingWithoutSpaces', additional('int', 4)])
|
||||||
|
|
||||||
def len(self, irc, msg, args):
|
def len(self, irc, msg, args, text):
|
||||||
"""<text>
|
"""<text>
|
||||||
|
|
||||||
Returns the length of <text>.
|
Returns the length of <text>.
|
||||||
"""
|
"""
|
||||||
total = 0
|
irc.reply(str(len(text)))
|
||||||
for arg in args:
|
len = wrap(len, ['text'])
|
||||||
total += len(arg)
|
|
||||||
total += len(args)-1 # spaces between the arguments.
|
|
||||||
irc.reply(str(total))
|
|
||||||
|
|
||||||
def re(self, irc, msg, args, ff, text):
|
def re(self, irc, msg, args, ff, text):
|
||||||
"""<regexp> <text>
|
"""<regexp> <text>
|
||||||
|
@ -77,6 +77,7 @@ class StringTestCase(PluginTestCase):
|
|||||||
plugins = ('String', 'Format', 'Status')
|
plugins = ('String', 'Format', 'Status')
|
||||||
def testLen(self):
|
def testLen(self):
|
||||||
self.assertResponse('len foo', '3')
|
self.assertResponse('len foo', '3')
|
||||||
|
self.assertHelp('len')
|
||||||
|
|
||||||
def testNoErrors(self):
|
def testNoErrors(self):
|
||||||
self.assertNotError('levenshtein Python Perl')
|
self.assertNotError('levenshtein Python Perl')
|
||||||
|
Loading…
Reference in New Issue
Block a user