diff options
author | Raphael Isemann <teemperor@gmail.com> | 2019-09-01 09:12:37 +0000 |
---|---|---|
committer | Raphael Isemann <teemperor@gmail.com> | 2019-09-01 09:12:37 +0000 |
commit | 29872606d220420d53fde7cc5e3bea15f8da62e7 (patch) | |
tree | 47d7a82ccea48a6dd10a2d8ecb6b3c3127724131 /lldb/packages/Python/lldbsuite/test/commands/expression/scoped_enums | |
parent | adfdcb9c2652aeee585b9005fd6c67be06af8ea9 (diff) | |
download | bcm5719-llvm-29872606d220420d53fde7cc5e3bea15f8da62e7.tar.gz bcm5719-llvm-29872606d220420d53fde7cc5e3bea15f8da62e7.zip |
[lldb] Restructure test folders to match LLDB command hierarchy
Summary:
As discussed on lldb-dev, this patch moves some LLDB tests into a hierarchy that more closely
resembles the commands we use in the LLDB interpreter. This patch should only move tests
that use the command interpreter and shouldn't touch any tests that primarily test the SB API.
Reviewers: #lldb, jfb, JDevlieghere
Reviewed By: #lldb, JDevlieghere
Subscribers: dexonsmith, arphaman, JDevlieghere, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D67033
llvm-svn: 370605
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/commands/expression/scoped_enums')
3 files changed, 67 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/scoped_enums/Makefile b/lldb/packages/Python/lldbsuite/test/commands/expression/scoped_enums/Makefile new file mode 100644 index 00000000000..83b24da17b4 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/scoped_enums/Makefile @@ -0,0 +1,6 @@ +LEVEL = ../../make + +CXX_SOURCES := main.cpp +CXXFLAGS += -std=c++11 + +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/scoped_enums/TestScopedEnumType.py b/lldb/packages/Python/lldbsuite/test/commands/expression/scoped_enums/TestScopedEnumType.py new file mode 100644 index 00000000000..e7bc79d8e7c --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/scoped_enums/TestScopedEnumType.py @@ -0,0 +1,45 @@ +from __future__ import print_function + + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class ScopedEnumType(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + @skipIf(dwarf_version=['<', '4']) + def test(self): + self.build() + + self.main_source = "main.cpp" + self.main_source_spec = lldb.SBFileSpec(self.main_source) + (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, + '// Set break point at this line.', self.main_source_spec) + frame = thread.GetFrameAtIndex(0) + + self.expect("expr f == Foo::FooBar", + substrs=['(bool) $0 = true']) + + value = frame.EvaluateExpression("f == Foo::FooBar") + self.assertTrue(value.IsValid()) + self.assertTrue(value.GetError().Success()) + self.assertEqual(value.GetValueAsUnsigned(), 1) + + value = frame.EvaluateExpression("b == BarBar") + self.assertTrue(value.IsValid()) + self.assertTrue(value.GetError().Success()) + self.assertEqual(value.GetValueAsUnsigned(), 1) + + ## b is not a Foo + value = frame.EvaluateExpression("b == Foo::FooBar") + self.assertTrue(value.IsValid()) + self.assertFalse(value.GetError().Success()) + + ## integral is not implicitly convertible to a scoped enum + value = frame.EvaluateExpression("1 == Foo::FooBar") + self.assertTrue(value.IsValid()) + self.assertFalse(value.GetError().Success()) diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/scoped_enums/main.cpp b/lldb/packages/Python/lldbsuite/test/commands/expression/scoped_enums/main.cpp new file mode 100644 index 00000000000..b0d67d23dc5 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/scoped_enums/main.cpp @@ -0,0 +1,16 @@ +enum class Foo { + FooBar = 42 +}; + +enum Bar { + BarBar = 3, + BarBarBar = 42 +}; + +int main(int argc, const char **argv) { + Foo f = Foo::FooBar; + Bar b = BarBar; + bool b1 = f == Foo::FooBar; + bool b2 = b == BarBar; + return 0; // Set break point at this line. +} |