Fix for bug #839053 (parens without bars not handled correctly).

This commit is contained in:
Jeremy Fincher 2003-11-10 10:46:57 +00:00
parent 830301570f
commit 9dd2680a9f
2 changed files with 14 additions and 1 deletions

View File

@ -79,7 +79,12 @@ class OptionList(object):
if not token: if not token:
raise SyntaxError, 'Missing ")"' raise SyntaxError, 'Missing ")"'
elif token == ')': elif token == ')':
return ret if len(ret) > 1:
return ret
elif len(ret) == 1:
return '(%s)' % ret[0]
else:
return '()'
elif token == '(': elif token == '(':
ret.append(self._insideParens(lexer)) ret.append(self._insideParens(lexer))
elif token == '|': elif token == '|':

View File

@ -37,6 +37,14 @@ except ImportError:
sqlite = None sqlite = None
if sqlite is not None: if sqlite is not None:
MoobotFactoids = Owner.loadPluginModule('MoobotFactoids')
class OptionListTestCase(unittest.TestCase):
def testEmptyParens(self):
self.assertEqual(MoobotFactoids.tokenize('()'), ['()'])
def testNoBarParens(self):
self.assertEqual(MoobotFactoids.tokenize('(foo)'), ['(foo)'])
class FactoidsTestCase(PluginTestCase, PluginDocumentation): class FactoidsTestCase(PluginTestCase, PluginDocumentation):
plugins = ('MoobotFactoids', 'User', 'Utilities') plugins = ('MoobotFactoids', 'User', 'Utilities')
def setUp(self): def setUp(self):