Ejemplo n.º 1
0
import unittest
from vint.ast.parsing import Parser
from test.asserting.ast import get_fixture_path

FIXTURE_FILE = get_fixture_path('fixture_to_parse.vim')


class TestParser(unittest.TestCase):
    def test_parse_file(self):
        parser = Parser()
        ast = parser.parse_file(FIXTURE_FILE)
        self.assertIs(ast['type'], 1)


if __name__ == '__main__':
    unittest.main()
Ejemplo n.º 2
0
import unittest
from test.asserting.ast import get_fixture_path

from vint.ast.parsing import Parser
from vint.ast.node_type import NodeType
from vint.ast.traversing import traverse, SKIP_CHILDREN

FIXTURE_FILE = get_fixture_path('fixture_to_traverse.vim')


class TestTraverse(unittest.TestCase):
    def setUp(self):
        parser = Parser()
        self.ast = parser.parse_file(FIXTURE_FILE)

    def test_traverse(self):
        expected_order_of_events = [
            {
                'node_type': NodeType.TOPLEVEL,
                'handler': 'enter'
            },
            {
                'node_type': NodeType.LET,
                'handler': 'enter'
            },
            {
                'node_type': NodeType.IDENTIFIER,
                'handler': 'enter'
            },
            {
                'node_type': NodeType.IDENTIFIER,
Ejemplo n.º 3
0
import unittest
from vint.ast.parsing import Parser
from vint.ast.node_type import NodeType
from vint.linting.lint_target import LintTargetFile
from test.asserting.ast import get_fixture_path

FIXTURE_FILE = get_fixture_path('fixture_to_parse.vim')
FIXTURE_FILE_EMPTY = get_fixture_path('fixture_to_parse_empty_file.vim')
FIXTURE_FILE_FF_DOS_FENC_CP932 = get_fixture_path('fixture_to_parse_windows.vim')
FIXTURE_FILE_NEOVIM = get_fixture_path('fixture_to_parse_neovim.vim')


class TestParser(unittest.TestCase):
    def test_parse(self):
        parser = Parser()
        ast = parser.parse(LintTargetFile(FIXTURE_FILE))
        self.assertIs(ast['type'], 1)


    def test_parse_file_on_ff_dos_and_fenc_cp932(self):
        parser = Parser()
        ast = parser.parse(LintTargetFile(FIXTURE_FILE_FF_DOS_FENC_CP932))
        self.assertIs(ast['type'], 1)


    def test_parse_file_when_neovim_enabled(self):
        parser = Parser(enable_neovim=True)
        ast = parser.parse(LintTargetFile(FIXTURE_FILE_NEOVIM))
        self.assertIs(ast['type'], 1)