Skip to content

Commit fe503b2

Browse files
author
hungtu
committed
aichaos#87 Add unit test for syntax check
1 parent 59416cd commit fe503b2

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,20 @@ def test_format_triggers(self):
3030
self.reply("hi there", "hi there")
3131
self.reply("hi here", "hi here")
3232

33+
def test_check_syntax(self):
34+
mismatch_brackets = ["a (b", "a [b", "a {b", "a <b", "a b)", "a b]", "a b}", "a b>"]
35+
empty_pipes = ["[a|b| ]", "[a|b|]", "[a| |c]", "[a||c]", "[ |b|c]", "[|b|c]"]
36+
37+
for failing_trigger in mismatch_brackets+empty_pipes:
38+
with self.assertRaises(Exception) as cm:
39+
self.new("""
40+
+ {}
41+
- hi
42+
""".format(failing_trigger))
43+
the_exception = cm.exception
44+
self.assertTrue(the_exception.message.startswith("Syntax error"))
45+
print "the_exception.message",the_exception.message
46+
3347
def test_invalid_character_raise_exception(self):
3448
self.assertRaises(Exception, self.new, """
3549
+ $hello

0 commit comments

Comments
 (0)