diff options
author | Thomas Preud'homme <thomasp@graphcore.ai> | 2019-05-23 00:10:29 +0000 |
---|---|---|
committer | Thomas Preud'homme <thomasp@graphcore.ai> | 2019-05-23 00:10:29 +0000 |
commit | f3b9bb3d69eb5468ac1c02b748f53da6328a7089 (patch) | |
tree | 2f0f9616892b6d73076e4a7fb238756f354bfbfa /llvm/unittests/Support/FileCheckTest.cpp | |
parent | 1a944d27b2b7fdd81106ac8e1ade2b6f5a8477dc (diff) | |
download | llvm-f3b9bb3d69eb5468ac1c02b748f53da6328a7089.zip llvm-f3b9bb3d69eb5468ac1c02b748f53da6328a7089.tar.gz llvm-f3b9bb3d69eb5468ac1c02b748f53da6328a7089.tar.bz2 |
[FileCheck] Introduce substitution subclasses
Summary:
With now a clear distinction between string and numeric substitutions,
this patch introduces separate classes to represent them with a parent
class implementing the common interface. Diagnostics in
printSubstitutions() are also adapted to not require knowing which
substitution is being looked at since it does not hinder clarity and
makes the implementation simpler.
Reviewers: jhenderson, jdenny, probinson, arichardson
Subscribers: llvm-commits, probinson, arichardson, hiraditya
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D62241
llvm-svn: 361446
Diffstat (limited to 'llvm/unittests/Support/FileCheckTest.cpp')
-rw-r--r-- | llvm/unittests/Support/FileCheckTest.cpp | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/llvm/unittests/Support/FileCheckTest.cpp b/llvm/unittests/Support/FileCheckTest.cpp index 5e157b2..dba6b59 100644 --- a/llvm/unittests/Support/FileCheckTest.cpp +++ b/llvm/unittests/Support/FileCheckTest.cpp @@ -229,9 +229,9 @@ TEST_F(FileCheckTest, Substitution) { Context.defineCmdlineVariables(GlobalDefines, SM); // Substitution of an undefined string variable fails. - FileCheckSubstitution Substitution = - FileCheckSubstitution(&Context, "VAR404", 42); - EXPECT_FALSE(Substitution.getResult()); + FileCheckStringSubstitution StringSubstitution = + FileCheckStringSubstitution(&Context, "VAR404", 42); + EXPECT_FALSE(StringSubstitution.getResult()); // Substitutions of defined pseudo and non-pseudo numeric variables return // the right value. @@ -239,10 +239,10 @@ TEST_F(FileCheckTest, Substitution) { FileCheckNumericVariable NVar = FileCheckNumericVariable("@N", 10); FileCheckNumExpr NumExprLine = FileCheckNumExpr(doAdd, &LineVar, 0); FileCheckNumExpr NumExprN = FileCheckNumExpr(doAdd, &NVar, 3); - FileCheckSubstitution SubstitutionLine = - FileCheckSubstitution(&Context, "@LINE", &NumExprLine, 12); - FileCheckSubstitution SubstitutionN = - FileCheckSubstitution(&Context, "N", &NumExprN, 30); + FileCheckNumericSubstitution SubstitutionLine = + FileCheckNumericSubstitution(&Context, "@LINE", &NumExprLine, 12); + FileCheckNumericSubstitution SubstitutionN = + FileCheckNumericSubstitution(&Context, "N", &NumExprN, 30); llvm::Optional<std::string> Value = SubstitutionLine.getResult(); EXPECT_TRUE(Value); EXPECT_EQ("42", *Value); @@ -258,8 +258,8 @@ TEST_F(FileCheckTest, Substitution) { // Substitution of a defined string variable returns the right value. FileCheckPattern P = FileCheckPattern(Check::CheckPlain, &Context); - Substitution = FileCheckSubstitution(&Context, "FOO", 42); - Value = Substitution.getResult(); + StringSubstitution = FileCheckStringSubstitution(&Context, "FOO", 42); + Value = StringSubstitution.getResult(); EXPECT_TRUE(Value); EXPECT_EQ("BAR", *Value); } @@ -273,29 +273,30 @@ TEST_F(FileCheckTest, UndefVars) { // getUndefVarName() on a string substitution with an undefined variable // returns that variable. - FileCheckSubstitution Substitution = - FileCheckSubstitution(&Context, "VAR404", 42); - StringRef UndefVar = Substitution.getUndefVarName(); + FileCheckStringSubstitution StringSubstitution = + FileCheckStringSubstitution(&Context, "VAR404", 42); + StringRef UndefVar = StringSubstitution.getUndefVarName(); EXPECT_EQ("VAR404", UndefVar); // getUndefVarName() on a string substitution with a defined variable returns // an empty string. - Substitution = FileCheckSubstitution(&Context, "FOO", 42); - UndefVar = Substitution.getUndefVarName(); + StringSubstitution = FileCheckStringSubstitution(&Context, "FOO", 42); + UndefVar = StringSubstitution.getUndefVarName(); EXPECT_EQ("", UndefVar); // getUndefVarName() on a numeric substitution with a defined variable // returns an empty string. FileCheckNumericVariable LineVar = FileCheckNumericVariable("@LINE", 42); FileCheckNumExpr NumExpr = FileCheckNumExpr(doAdd, &LineVar, 0); - Substitution = FileCheckSubstitution(&Context, "@LINE", &NumExpr, 12); - UndefVar = Substitution.getUndefVarName(); + FileCheckNumericSubstitution NumericSubstitution = + FileCheckNumericSubstitution(&Context, "@LINE", &NumExpr, 12); + UndefVar = NumericSubstitution.getUndefVarName(); EXPECT_EQ("", UndefVar); // getUndefVarName() on a numeric substitution with an undefined variable // returns that variable. LineVar.clearValue(); - UndefVar = Substitution.getUndefVarName(); + UndefVar = NumericSubstitution.getUndefVarName(); EXPECT_EQ("@LINE", UndefVar); } |