rC355158 added an optional language parameter to getLLVMStyle(), but this parameter was not used in getPredefinedStyle(). Because unit tests directly specify the style, this codepath wasn't tested. Add an additional unit test for getStyle().
llvm-svn: 356099
bool getPredefinedStyle(StringRef Name, FormatStyle::LanguageKind Language,
FormatStyle *Style) {
if (Name.equals_lower("llvm")) {
- *Style = getLLVMStyle();
+ *Style = getLLVMStyle(Language);
} else if (Name.equals_lower("chromium")) {
*Style = getChromiumStyle(Language);
} else if (Name.equals_lower("mozilla")) {
auto Style7 = getStyle("file", "/d/.clang-format", "LLVM", "", &FS);
ASSERT_FALSE((bool)Style7);
llvm::consumeError(Style7.takeError());
+
+ // Test 8: inferred per-language defaults apply.
+ auto StyleTd = getStyle("file", "x.td", "llvm", "", &FS);
+ ASSERT_TRUE((bool)StyleTd);
+ ASSERT_EQ(*StyleTd, getLLVMStyle(FormatStyle::LK_TableGen));
}
TEST_F(ReplacementTest, FormatCodeAfterReplacements) {