mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-23 02:24:12 +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))
|
||||
soundex = wrap(soundex, ['somethingWithoutSpaces', additional('int', 4)])
|
||||
|
||||
def len(self, irc, msg, args):
|
||||
def len(self, irc, msg, args, text):
|
||||
"""<text>
|
||||
|
||||
Returns the length of <text>.
|
||||
"""
|
||||
total = 0
|
||||
for arg in args:
|
||||
total += len(arg)
|
||||
total += len(args)-1 # spaces between the arguments.
|
||||
irc.reply(str(total))
|
||||
irc.reply(str(len(text)))
|
||||
len = wrap(len, ['text'])
|
||||
|
||||
def re(self, irc, msg, args, ff, text):
|
||||
"""<regexp> <text>
|
||||
|
@ -77,6 +77,7 @@ class StringTestCase(PluginTestCase):
|
||||
plugins = ('String', 'Format', 'Status')
|
||||
def testLen(self):
|
||||
self.assertResponse('len foo', '3')
|
||||
self.assertHelp('len')
|
||||
|
||||
def testNoErrors(self):
|
||||
self.assertNotError('levenshtein Python Perl')
|
||||
|
Loading…
Reference in New Issue
Block a user