diff options
author | Thomas Preud'homme <thomasp@graphcore.ai> | 2019-07-10 12:49:28 +0000 |
---|---|---|
committer | Thomas Preud'homme <thomasp@graphcore.ai> | 2019-07-10 12:49:28 +0000 |
commit | 2bf04f25ff0d56710e12228a00fdd60501d7746e (patch) | |
tree | c6ca96d31f844cd9de569fb9898e19f5b392faa9 /llvm/unittests/Support/FileCheckTest.cpp | |
parent | f6ea43b8b302acfae974065f0aa16e7432db099e (diff) | |
download | llvm-2bf04f25ff0d56710e12228a00fdd60501d7746e.zip llvm-2bf04f25ff0d56710e12228a00fdd60501d7746e.tar.gz llvm-2bf04f25ff0d56710e12228a00fdd60501d7746e.tar.bz2 |
[FileCheck] Simplify numeric variable interface
Summary:
This patch simplifies 2 aspects in the FileCheckNumericVariable code.
First, setValue() method is turned into a void function since being
called only on undefined variable is an invariant and is now asserted
rather than returned. This remove the assert from the callers.
Second, clearValue() method is also turned into a void function since
the only caller does not check its return value since it may be trying
to clear the value of variable that is already cleared without this
being noteworthy.
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: JonChesterfield, rogfer01, hfinkel, kristina, rnk, tra, arichardson, grimar, dblaikie, probinson, llvm-commits, hiraditya
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D64231
> llvm-svn: 365249
llvm-svn: 365625
Diffstat (limited to 'llvm/unittests/Support/FileCheckTest.cpp')
-rw-r--r-- | llvm/unittests/Support/FileCheckTest.cpp | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/llvm/unittests/Support/FileCheckTest.cpp b/llvm/unittests/Support/FileCheckTest.cpp index 58550c7..848ab15 100644 --- a/llvm/unittests/Support/FileCheckTest.cpp +++ b/llvm/unittests/Support/FileCheckTest.cpp @@ -15,28 +15,23 @@ namespace { class FileCheckTest : public ::testing::Test {}; TEST_F(FileCheckTest, NumericVariable) { - // Undefined variable: getValue and clearValue fails, setValue works. + // Undefined variable: getValue fails, setValue does not trigger assert. FileCheckNumericVariable FooVar = FileCheckNumericVariable(1, "FOO"); EXPECT_EQ("FOO", FooVar.getName()); llvm::Optional<uint64_t> Value = FooVar.getValue(); EXPECT_FALSE(Value); - EXPECT_TRUE(FooVar.clearValue()); - EXPECT_FALSE(FooVar.setValue(42)); + FooVar.clearValue(); + FooVar.setValue(42); - // Defined variable: getValue returns value set, setValue fails. - Value = FooVar.getValue(); - EXPECT_TRUE(Value); - EXPECT_EQ(42U, *Value); - EXPECT_TRUE(FooVar.setValue(43)); + // Defined variable: getValue returns value set. Value = FooVar.getValue(); EXPECT_TRUE(Value); EXPECT_EQ(42U, *Value); - // Clearing variable: getValue fails, clearValue again fails. - EXPECT_FALSE(FooVar.clearValue()); + // Clearing variable: getValue fails. + FooVar.clearValue(); Value = FooVar.getValue(); EXPECT_FALSE(Value); - EXPECT_TRUE(FooVar.clearValue()); } uint64_t doAdd(uint64_t OpL, uint64_t OpR) { return OpL + OpR; } |