def testEncoded(self): file = StringIO(u'foo\nbär'.encode('utf-8')) stream = antlr3.InputStream(file, 'utf-8') stream.seek(4) marker1 = stream.mark() stream.consume() marker2 = stream.mark() stream.consume() marker3 = stream.mark() stream.rewind(marker2) self.failUnlessEqual(stream.markDepth, 1) self.failUnlessEqual(stream.index(), 5) self.failUnlessEqual(stream.line, 2) self.failUnlessEqual(stream.charPositionInLine, 1) self.failUnlessEqual(stream.LA(1), u'ä')
def testNoEncoding(self): file = StringIO('foo\nbar') stream = antlr3.InputStream(file) stream.seek(4) marker1 = stream.mark() stream.consume() marker2 = stream.mark() stream.consume() marker3 = stream.mark() stream.rewind(marker2) self.failUnlessEqual(stream.markDepth, 1) self.failUnlessEqual(stream.index(), 5) self.failUnlessEqual(stream.line, 2) self.failUnlessEqual(stream.charPositionInLine, 1) self.failUnlessEqual(stream.LA(1), 'a')
def testEncoded(self): file = StringIO('foo\nbär') stream = antlr3.InputStream(file) stream.seek(4) marker1 = stream.mark() stream.consume() marker2 = stream.mark() stream.consume() marker3 = stream.mark() stream.rewind(marker2) self.assertEqual(stream.markDepth, 1) self.assertEqual(stream.index(), 5) self.assertEqual(stream.line, 2) self.assertEqual(stream.charPositionInLine, 1) self.assertEqual(stream.LT(1), 'ä') self.assertEqual(stream.LA(1), ord('ä'))