Beispiel #1
0
class ParserTests(unittest.TestCase):
	def setUp(self):
		self.parser = Parser()

	def testCorrectSquareBrackets(self):
		self.assertTrue(self.parser.read("[]"))

	def testFalseSquareBrackets(self):
		self.assertFalse(self.parser.read("[]]"))

	def testCorrectMixedBrackets(self):
		self.assertTrue(self.parser.read("{<>}()[{}]"))

	def testFalseMixedBrackets(self):
		self.assertFalse(self.parser.read("{<}()[{}]"))

	def testTokenExistsButOrderIsWrong(self):
		self.assertFalse(self.parser.read("{[}]"))

	def testLargeString(self):
		eval_this = """
			{}<>()[]{}<>()[]{}<>()[]{}<>()[]{}<>()[]{}<>()[]{}<>()[]
			{}<>()[]{}<>()[]{}<>()[]{}<>()[]{}<>()[]{}<>()[]{}<>()[]
			{}<>()[]{}<>()[]{}<>()[]{}<>()[]{}<>()[]{}<>()[]{}<>()[]
			{}<>()[]{}<>()[]{}<>()[]{}<>()[]{}<>()[]{}<>()[]{}<>()[]
			{}<>()[]{}<>()[]{}<>()[]{}<>()[]{}<>()[]{}<>()[]{}<>()[]
		"""
		self.assertTrue(self.parser.read(eval_this))

	def testFalseLargeString(self):
		# SyntaxError in line 41
		eval_this = """
			{}<>()[]{}<>()[]{}<>()[]{}<>()[]{}<>()[]{}<>()[]{}<>()[]
			{}<>()[]{}<>()[]{}<>()[]{}<>()[]{}<>()[]{}<>()[]{}<>()[]
			{}<>()[]{}<>()[]{}<>()[]{}<>()[]{}<>()[]{}<>()[]{}<>()[]
			{}<>()[]{}<>()[]{}<()[]{}<>()[]{}<>()[]{}<>()[]{}<>()[]
			{}<>()[]{}<>()[]{}<>()[]{}<>()[]{}<>()[]{}<>()[]{}<>()[]
		"""
		self.assertFalse(self.parser.read(eval_this))
Beispiel #2
0
def main(args):
	parser = Parser()
	print parser.read("<{}<>()")