mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 04:02:41 +01:00
[NFC] [FileCheck] Reapply fix init of objects in unit tests
Summary: Fix initialization style of objects allocated on the stack and member objects in unit test to use the "Type Var(init list)" and "Type Member{init list}" convention. The latter fixes the buildbot breakage. Reviewers: jhenderson, probinson, arichardson, grimar, jdenny Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D68425 llvm-svn: 373755
This commit is contained in:
parent
4723a65db1
commit
daf204792f
@ -62,10 +62,9 @@ uint64_t doAdd(uint64_t OpL, uint64_t OpR) { return OpL + OpR; }
|
|||||||
TEST_F(FileCheckTest, NumericVariable) {
|
TEST_F(FileCheckTest, NumericVariable) {
|
||||||
// Undefined variable: getValue and eval fail, error returned by eval holds
|
// Undefined variable: getValue and eval fail, error returned by eval holds
|
||||||
// the name of the undefined variable.
|
// the name of the undefined variable.
|
||||||
FileCheckNumericVariable FooVar = FileCheckNumericVariable("FOO", 1);
|
FileCheckNumericVariable FooVar("FOO", 1);
|
||||||
EXPECT_EQ("FOO", FooVar.getName());
|
EXPECT_EQ("FOO", FooVar.getName());
|
||||||
FileCheckNumericVariableUse FooVarUse =
|
FileCheckNumericVariableUse FooVarUse("FOO", &FooVar);
|
||||||
FileCheckNumericVariableUse("FOO", &FooVar);
|
|
||||||
EXPECT_FALSE(FooVar.getValue());
|
EXPECT_FALSE(FooVar.getValue());
|
||||||
Expected<uint64_t> EvalResult = FooVarUse.eval();
|
Expected<uint64_t> EvalResult = FooVarUse.eval();
|
||||||
ASSERT_FALSE(EvalResult);
|
ASSERT_FALSE(EvalResult);
|
||||||
@ -91,16 +90,15 @@ TEST_F(FileCheckTest, NumericVariable) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(FileCheckTest, Binop) {
|
TEST_F(FileCheckTest, Binop) {
|
||||||
FileCheckNumericVariable FooVar = FileCheckNumericVariable("FOO", 1);
|
FileCheckNumericVariable FooVar("FOO", 1);
|
||||||
FooVar.setValue(42);
|
FooVar.setValue(42);
|
||||||
std::unique_ptr<FileCheckNumericVariableUse> FooVarUse =
|
std::unique_ptr<FileCheckNumericVariableUse> FooVarUse =
|
||||||
std::make_unique<FileCheckNumericVariableUse>("FOO", &FooVar);
|
std::make_unique<FileCheckNumericVariableUse>("FOO", &FooVar);
|
||||||
FileCheckNumericVariable BarVar = FileCheckNumericVariable("BAR", 2);
|
FileCheckNumericVariable BarVar("BAR", 2);
|
||||||
BarVar.setValue(18);
|
BarVar.setValue(18);
|
||||||
std::unique_ptr<FileCheckNumericVariableUse> BarVarUse =
|
std::unique_ptr<FileCheckNumericVariableUse> BarVarUse =
|
||||||
std::make_unique<FileCheckNumericVariableUse>("BAR", &BarVar);
|
std::make_unique<FileCheckNumericVariableUse>("BAR", &BarVar);
|
||||||
FileCheckASTBinop Binop =
|
FileCheckASTBinop Binop(doAdd, std::move(FooVarUse), std::move(BarVarUse));
|
||||||
FileCheckASTBinop(doAdd, std::move(FooVarUse), std::move(BarVarUse));
|
|
||||||
|
|
||||||
// Defined variable: eval returns right value.
|
// Defined variable: eval returns right value.
|
||||||
Expected<uint64_t> Value = Binop.eval();
|
Expected<uint64_t> Value = Binop.eval();
|
||||||
@ -217,8 +215,7 @@ private:
|
|||||||
SourceMgr SM;
|
SourceMgr SM;
|
||||||
FileCheckRequest Req;
|
FileCheckRequest Req;
|
||||||
FileCheckPatternContext Context;
|
FileCheckPatternContext Context;
|
||||||
FileCheckPattern P =
|
FileCheckPattern P{Check::CheckPlain, &Context, LineNumber++};
|
||||||
FileCheckPattern(Check::CheckPlain, &Context, LineNumber++);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PatternTester() {
|
PatternTester() {
|
||||||
@ -409,25 +406,24 @@ TEST_F(FileCheckTest, Substitution) {
|
|||||||
|
|
||||||
// Substitution of an undefined string variable fails and error holds that
|
// Substitution of an undefined string variable fails and error holds that
|
||||||
// variable's name.
|
// variable's name.
|
||||||
FileCheckStringSubstitution StringSubstitution =
|
FileCheckStringSubstitution StringSubstitution(&Context, "VAR404", 42);
|
||||||
FileCheckStringSubstitution(&Context, "VAR404", 42);
|
|
||||||
Expected<std::string> SubstValue = StringSubstitution.getResult();
|
Expected<std::string> SubstValue = StringSubstitution.getResult();
|
||||||
ASSERT_FALSE(bool(SubstValue));
|
ASSERT_FALSE(bool(SubstValue));
|
||||||
expectUndefError("VAR404", SubstValue.takeError());
|
expectUndefError("VAR404", SubstValue.takeError());
|
||||||
|
|
||||||
// Substitutions of defined pseudo and non-pseudo numeric variables return
|
// Substitutions of defined pseudo and non-pseudo numeric variables return
|
||||||
// the right value.
|
// the right value.
|
||||||
FileCheckNumericVariable LineVar = FileCheckNumericVariable("@LINE", 1);
|
FileCheckNumericVariable LineVar("@LINE", 1);
|
||||||
FileCheckNumericVariable NVar = FileCheckNumericVariable("N", 1);
|
FileCheckNumericVariable NVar("N", 1);
|
||||||
LineVar.setValue(42);
|
LineVar.setValue(42);
|
||||||
NVar.setValue(10);
|
NVar.setValue(10);
|
||||||
auto LineVarUse =
|
auto LineVarUse =
|
||||||
std::make_unique<FileCheckNumericVariableUse>("@LINE", &LineVar);
|
std::make_unique<FileCheckNumericVariableUse>("@LINE", &LineVar);
|
||||||
auto NVarUse = std::make_unique<FileCheckNumericVariableUse>("N", &NVar);
|
auto NVarUse = std::make_unique<FileCheckNumericVariableUse>("N", &NVar);
|
||||||
FileCheckNumericSubstitution SubstitutionLine = FileCheckNumericSubstitution(
|
FileCheckNumericSubstitution SubstitutionLine(&Context, "@LINE",
|
||||||
&Context, "@LINE", std::move(LineVarUse), 12);
|
std::move(LineVarUse), 12);
|
||||||
FileCheckNumericSubstitution SubstitutionN =
|
FileCheckNumericSubstitution SubstitutionN(&Context, "N", std::move(NVarUse),
|
||||||
FileCheckNumericSubstitution(&Context, "N", std::move(NVarUse), 30);
|
30);
|
||||||
SubstValue = SubstitutionLine.getResult();
|
SubstValue = SubstitutionLine.getResult();
|
||||||
ASSERT_TRUE(bool(SubstValue));
|
ASSERT_TRUE(bool(SubstValue));
|
||||||
EXPECT_EQ("42", *SubstValue);
|
EXPECT_EQ("42", *SubstValue);
|
||||||
@ -447,7 +443,7 @@ TEST_F(FileCheckTest, Substitution) {
|
|||||||
expectUndefError("N", SubstValue.takeError());
|
expectUndefError("N", SubstValue.takeError());
|
||||||
|
|
||||||
// Substitution of a defined string variable returns the right value.
|
// Substitution of a defined string variable returns the right value.
|
||||||
FileCheckPattern P = FileCheckPattern(Check::CheckPlain, &Context, 1);
|
FileCheckPattern P(Check::CheckPlain, &Context, 1);
|
||||||
StringSubstitution = FileCheckStringSubstitution(&Context, "FOO", 42);
|
StringSubstitution = FileCheckStringSubstitution(&Context, "FOO", 42);
|
||||||
SubstValue = StringSubstitution.getResult();
|
SubstValue = StringSubstitution.getResult();
|
||||||
ASSERT_TRUE(bool(SubstValue));
|
ASSERT_TRUE(bool(SubstValue));
|
||||||
@ -455,7 +451,7 @@ TEST_F(FileCheckTest, Substitution) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(FileCheckTest, FileCheckContext) {
|
TEST_F(FileCheckTest, FileCheckContext) {
|
||||||
FileCheckPatternContext Cxt = FileCheckPatternContext();
|
FileCheckPatternContext Cxt;
|
||||||
std::vector<std::string> GlobalDefines;
|
std::vector<std::string> GlobalDefines;
|
||||||
SourceMgr SM;
|
SourceMgr SM;
|
||||||
|
|
||||||
@ -518,7 +514,7 @@ TEST_F(FileCheckTest, FileCheckContext) {
|
|||||||
StringRef EmptyVarStr = "EmptyVar";
|
StringRef EmptyVarStr = "EmptyVar";
|
||||||
StringRef UnknownVarStr = "UnknownVar";
|
StringRef UnknownVarStr = "UnknownVar";
|
||||||
Expected<StringRef> LocalVar = Cxt.getPatternVarValue(LocalVarStr);
|
Expected<StringRef> LocalVar = Cxt.getPatternVarValue(LocalVarStr);
|
||||||
FileCheckPattern P = FileCheckPattern(Check::CheckPlain, &Cxt, 1);
|
FileCheckPattern P(Check::CheckPlain, &Cxt, 1);
|
||||||
Optional<FileCheckNumericVariable *> DefinedNumericVariable;
|
Optional<FileCheckNumericVariable *> DefinedNumericVariable;
|
||||||
Expected<std::unique_ptr<FileCheckExpressionAST>> ExpressionAST =
|
Expected<std::unique_ptr<FileCheckExpressionAST>> ExpressionAST =
|
||||||
P.parseNumericSubstitutionBlock(LocalNumVar1Ref, DefinedNumericVariable,
|
P.parseNumericSubstitutionBlock(LocalNumVar1Ref, DefinedNumericVariable,
|
||||||
|
Loading…
Reference in New Issue
Block a user