예제 #1
0
 def test_asciimatics_parser(self):
     """
     Check AsciimaticsParser works as expected.
     """
     parser = AsciimaticsParser()
     tokens = parser.parse("a${1}b${2,1}c${3,2,4}de", None)
     self.assertEquals(next(tokens), ("a", (None, None, None), 0))
     self.assertEquals(next(tokens), ("b", (1, 0, None), 1))
     self.assertEquals(next(tokens), ("c", (2, 1, None), 6))
     self.assertEquals(next(tokens), ("d", (3, 2, 4), 13))
     self.assertEquals(next(tokens), ("e", (3, 2, 4), 22))
     with self.assertRaises(StopIteration):
         next(tokens)
예제 #2
0
 def test_asciimatics_parser(self):
     """
     Check AsciimaticsParser works as expected.
     """
     parser = AsciimaticsParser()
     parser.reset("a${1}b${2,1}c${3,2,4}de${7}", None)
     tokens = parser.parse()
     self.assertEquals(next(tokens), (0, Parser.DISPLAY_TEXT, "a"))
     self.assertEquals(next(tokens),
                       (1, Parser.CHANGE_COLOURS, (1, 0, None)))
     self.assertEquals(next(tokens), (1, Parser.DISPLAY_TEXT, "b"))
     self.assertEquals(next(tokens),
                       (6, Parser.CHANGE_COLOURS, (2, 1, None)))
     self.assertEquals(next(tokens), (6, Parser.DISPLAY_TEXT, "c"))
     self.assertEquals(next(tokens), (13, Parser.CHANGE_COLOURS, (3, 2, 4)))
     self.assertEquals(next(tokens), (13, Parser.DISPLAY_TEXT, "d"))
     self.assertEquals(next(tokens), (22, Parser.DISPLAY_TEXT, "e"))
     self.assertEquals(next(tokens),
                       (23, Parser.CHANGE_COLOURS, (7, 0, None)))
     with self.assertRaises(StopIteration):
         next(tokens)