Beispiel #1
0
 def test_8(self):
     cg = list(
         _classify_groups([[
             (_GROUP.block_comment_start, 0, '/* multi-\n')
         ], [(_GROUP.block_comment_body, 3, '   line\n')
             ], [(_GROUP.block_comment_end, 3, '   comment */')]], c_lexer))
     assert cg == [(0, 'multi-\n'), (0, 'line\n'), (0, 'comment ')]
Beispiel #2
0
 def test_9(self):
     cg = list( _classify_groups([
       [(_GROUP.block_comment_start, 2, '/*multi-\n')],
       [(_GROUP.block_comment_body,  2, '  line\n')],
       [(_GROUP.block_comment_end,   2, '  comment*/')]], c_lexer) )
     assert cg == [(-1, '/*multi-\n'),
                   (-1, '  line\n'),
                   (-1, '  comment*/')]
Beispiel #3
0
 def test_10(self):
     lexer = get_lexer_by_name('c')
     token_iter = lex(self.test_c_code, lexer)
     token_group = _group_lexer_tokens(token_iter, False, False)
     gathered_group = _gather_groups_on_newlines(token_group, (2, 2, 2))
     classified_group = list(_classify_groups(gathered_group, c_lexer))
     assert classified_group == [(-1, '#include <stdio.h>\n'), (-1, '\n'),
                                 (0, 'A multi-\n'), (0, 'line\n'),
                                 (0, 'comment \n'), (-1, '\n'),
                                 (-1, 'main(){\n'), (2, 'Empty.\n'),
                                 (-1, '}\n')]
Beispiel #4
0
 def test_10(self):
     lexer = get_lexer_by_name('c')
     token_iter = lex(self.test_c_code, lexer)
     token_group = _group_lexer_tokens(token_iter, False, False)
     gathered_group = _gather_groups_on_newlines(token_group, (2, 2, 2))
     classified_group = list( _classify_groups(gathered_group, c_lexer) )
     assert classified_group == [(-1, '#include <stdio.h>\n'),
                                 (-1, '\n'),
                                 ( 0, 'A multi-\n'),
                                 ( 0, 'line\n'),
                                 ( 0, 'comment \n'),
                                 (-1, '\n'),
                                 (-1, 'main(){\n'),
                                 ( 2,   'Empty.\n'),
                                 (-1, '}\n')]
Beispiel #5
0
 def test_7(self):
     cg = list( _classify_groups([[
       (_GROUP.whitespace, 0, '  '),
       (_GROUP.other, 0, 'foo();'),
       (_GROUP.whitespace, 0, '\n')]], c_lexer) )
     assert cg == [(-1, '  foo();\n')]
Beispiel #6
0
 def test_6(self):
     cg = list( _classify_groups([[
       (_GROUP.whitespace, 0, '  '),
       (_GROUP.inline_comment, 0, '// comment\n')]], c_lexer) )
     assert cg == [(2, 'comment\n')]
Beispiel #7
0
 def test_5(self):
     cg = list( _classify_groups([[
       (_GROUP.inline_comment, 0, '// comment\n')]], c_lexer) )
     assert cg == [(0, 'comment\n')]
Beispiel #8
0
 def test_7(self):
     cg = list(
         _classify_groups([[(_GROUP.whitespace, 0, '  '),
                            (_GROUP.other, 0, 'foo();'),
                            (_GROUP.whitespace, 0, '\n')]], c_lexer))
     assert cg == [(-1, '  foo();\n')]
Beispiel #9
0
 def test_6(self):
     cg = list(
         _classify_groups([[(_GROUP.whitespace, 0, '  '),
                            (_GROUP.inline_comment, 0, '// comment\n')]],
                          c_lexer))
     assert cg == [(2, 'comment\n')]
Beispiel #10
0
 def test_5(self):
     cg = list(
         _classify_groups([[(_GROUP.inline_comment, 0, '// comment\n')]],
                          c_lexer))
     assert cg == [(0, 'comment\n')]