Made <number> optional in convert.

This commit is contained in:
Jeremy Fincher 2003-10-23 04:21:40 +00:00
parent 65b87f822c
commit 8914543d35
2 changed files with 8 additions and 3 deletions

View File

@ -212,13 +212,17 @@ class Math(callbacks.Privmsg):
if isinstance(v, unum.Unum):
_convertEnv[k.lower()] = v
def convert(self, irc, msg, args):
"""<number> <units> to <other units>
"""[<number>] <units> to <other units>
Converts the first number of <units> to the <other units>. Valid units
expressions include the standard Python math operators applied to valid
units.
units. If <number> isn't given, it defaults to 1.
"""
(n, unit1, to, unit2) = privmsgs.getArgs(args, needed=4)
if args and args[0].isdigit():
n = args.pop(0)
else:
n = 1
(unit1, to, unit2) = privmsgs.getArgs(args, needed=3)
if to != 'to':
raise callbacks.ArgumentError
try:

View File

@ -62,6 +62,7 @@ class MathTestCase(PluginTestCase, PluginDocumentation):
def testConvert(self):
self.assertResponse('convert 1 m to cm', '100.0 cm')
self.assertResponse('convert m to cm', '100.0 cm')
self.assertResponse('convert 1 M to cm', '100.0 cm')
self.assertResponse('convert 1 m to CM', '100.0 cm')
self.assertResponse('convert 1 m to cM', '100.0 cm')