Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions llvm/utils/llvm-test-mustache-spec/llvm-test-mustache-spec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ static const StringMap<StringSet<>> XFailTestNames = {{
}};

struct TestData {
TestData() = default;
explicit TestData(const json::Object &TestCase)
: TemplateStr(*TestCase.getString("template")),
ExpectedStr(*TestCase.getString("expected")),
Name(*TestCase.getString("name")), Data(TestCase.get("data")),
Partials(TestCase.get("partials")) {}

static Expected<TestData> createTestData(json::Object *TestCase,
StringRef InputFile) {
// If any of the needed elements are missing, we cannot continue.
Expand All @@ -157,19 +164,14 @@ struct TestData {
llvm::inconvertibleErrorCode(),
"invalid JSON schema in test file: " + InputFile + "\n");

return TestData{TestCase->getString("template").value(),
TestCase->getString("expected").value(),
TestCase->getString("name").value(), TestCase->get("data"),
TestCase->get("partials")};
return TestData(*TestCase);
}

TestData() = default;

StringRef TemplateStr;
StringRef ExpectedStr;
StringRef Name;
Value *Data;
Value *Partials;
const Value *Data;
const Value *Partials;
};

static void reportTestFailure(const TestData &TD, StringRef ActualStr,
Expand All @@ -191,7 +193,7 @@ static void reportTestFailure(const TestData &TD, StringRef ActualStr,
}
}

static void registerPartials(Value *Partials, Template &T) {
static void registerPartials(const Value *Partials, Template &T) {
if (!Partials)
return;
for (const auto &[Partial, Str] : *Partials->getAsObject())
Expand Down
Loading