def test_no_syntax_raises_notimplemented(self): syn = SyntaxerBase(self.reporter) lxr = WordLexer(FileSource(self.fp), FileIteratorTracking(self.fp), self.reporter) # should throw an error, because no syntax there with self.assertRaises(NotImplementedError): syn.parse(lxr)
def setUp(self): self.fp = 'gio/test/test_doc_tracker' self.reporter = ReporterStreamConsole(1, 1) self.lxr = WordLexer(FileSource(self.fp), FileIteratorTracking(self.fp), self.reporter) for x in range(0, 8): next(self.lxr)
def test_tokens_all(self): fp = 'test/test_doc_tokens_all' it = FileIteratorTracking(fp) tkIt = Lexer(FileSource(fp), it, self.reporter) outStream = [tok for tok in tkIt] anticipatedStream = [ Tokens.COMMENT, Tokens.MULTILINE_COMMENT, Tokens.LINEFEED, Tokens.STRING, Tokens.LINEFEED, Tokens.STRING, Tokens.LINEFEED, Tokens.INT_NUM, Tokens.FLOAT_NUM, Tokens.LINEFEED, Tokens.COMMA, Tokens.COLON, Tokens.LBRACKET, Tokens.RBRACKET, Tokens.LINEFEED, Tokens.IDENTIFIER, Tokens.IDENTIFIER, Tokens.IDENTIFIER, Tokens.LINEFEED, Tokens.LCOLL, Tokens.RCOLL, Tokens.LINEFEED, Tokens.LPATH, Tokens.RPATH, Tokens.LINEFEED, Tokens.KEY_VALUE, Tokens.LINEFEED, Tokens.REPEAT, ] self.assertEqual(outStream, anticipatedStream)
def test_error_raises_gioerror(self): lxr = WordLexer(FileSource(self.fp), FileIteratorTracking(self.fp), self.reporter) self.syn.parse(lxr) with self.assertRaises(GIOSyntaxError): self.syn.error('ouch!')
def test_parse(self): lxr = WordLexer(FileSource(self.fp), FileIteratorTracking(self.fp), self.reporter) self.syn.parse(lxr)
def setUp(self): fp = 'gio/test/test_doc_tracker' self.it = FileIteratorTracking(fp) self.reporter = ReporterStreamConsole(0, 0) self.tkIt = LexerBase(FileSource(fp), self.it, self.reporter)
def test_tok_start(self): tkIt = Lexer(FileSource(self.fp), self.it, self.reporter) tok = next(tkIt) self.assertEqual(tok, Tokens.LINEFEED) tok = next(tkIt) self.assertEqual(tok, Tokens.IDENTIFIER)
def setUp(self): self.fp = 'test/test_doc_rubble' self.it = FileIteratorTracking(self.fp) self.reporter = ReporterStreamConsole(1, 1) self.tkIt = Lexer(FileSource(self.fp), self.it, self.reporter)
def setUp(self): self.pos = Position(0, 7) self.msg = Message.withPos('Rain', FileSource('some/path/end.py'), self.pos, 'return a') self.rp = ReporterStreamConsole(0, 0)
def setUp(self): self.pos = Position(0, 7) self.msg = Message.withPos('Rain', FileSource('some/path/end.py'), self.pos, 'return a')
def test_init(self): lxr = WordLexer(FileSource(self.fp), FileIteratorTracking(self.fp), self.reporter) # Not much to look at self.assertEqual(lxr.tokenLineCount, 0) self.assertEqual(lxr.tokenStartOffset, 0)