Esempio n. 1
0
    def test_yaml_map_list(self):
        res = whatstyle.parse_miniyaml("""\
---
Language:        Cpp
# BasedOnStyle:  LLVM
AccessModifierOffset: -2
BraceWrapping:
  AfterClass:      false
  AfterControlStatement: false
IncludeCategories:
  - Regex:           '^"(llvm|llvm-c|clang|clang-c)/'
    Priority:        2
  - Regex:           '.*'
    Priority:        1
IndentCaseLabels: false
...
""")
        # yapf: disable
        expected = OrderedDict([('Language', 'Cpp'),
                                ('BasedOnStyle', 'LLVM'),
                                ('AccessModifierOffset', -2),
                                ('BraceWrapping', OrderedDict([
                                    ('AfterClass', False),
                                    ('AfterControlStatement', False)])),
                                ('IncludeCategories',
                                 [OrderedDict([(
                                     'Regex', '^"(llvm|llvm-c|clang|clang-c)/'),
                                     ('Priority', 2)]),
                                  OrderedDict([(
                                     'Regex', '.*'),
                                     ('Priority', 1)])]),
                                ('IndentCaseLabels', False)])
        # yapf: enable
        self.assertMultiLineEqual(self.jenc(res), self.jenc(expected))
Esempio n. 2
0
    def test_yaml_inline_list(self):
        res = whatstyle.parse_miniyaml("""\
ForEachMacros:   [ foreach, Q_FOREACH, BOOST_FOREACH ]
""")
        # yapf: disable
        expected = OrderedDict([('ForEachMacros', ["foreach", "Q_FOREACH", "BOOST_FOREACH"])])
        # yapf: enable
        self.assertMultiLineEqual(self.jenc(res), self.jenc(expected))
Esempio n. 3
0
    def test_yaml(self):
        res = whatstyle.parse_miniyaml("""\
---
Language:        Cpp
# BasedOnStyle:  LLVM
...
""")
        self.assertEqual(
            res, OrderedDict([('Language', 'Cpp'), ('BasedOnStyle', 'LLVM')]))
Esempio n. 4
0
    def test_yaml_plain_list(self):
        res = whatstyle.parse_miniyaml("""\
---
ForEachMacros:
  - foreach
  - Q_FOREACH
  - BOOST_FOREACH
...
""")
        # yapf: disable
        expected = OrderedDict([('ForEachMacros', ["foreach", "Q_FOREACH", "BOOST_FOREACH"])])
        # yapf: enable
        self.assertMultiLineEqual(self.jenc(res), self.jenc(expected))
Esempio n. 5
0
    def test_yaml_2(self):
        res = whatstyle.parse_miniyaml("""\
---
IncludeCategories:
  - Regex:           '^"(llvm|llvm-c|clang|clang-c)/'
    Priority:        2
""")
        self.assertEqual(
            res,
            OrderedDict([('IncludeCategories', [
                OrderedDict([('Regex', '^"(llvm|llvm-c|clang|clang-c)/'),
                             ('Priority', 2)])
            ])]))