diff options
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/lang/cpp')
4 files changed, 61 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/operator-overload/Makefile b/lldb/packages/Python/lldbsuite/test/lang/cpp/operator-overload/Makefile new file mode 100644 index 00000000000..7d85a3a81f8 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/operator-overload/Makefile @@ -0,0 +1,20 @@ +LEVEL = ../../../make + +CXX_SOURCES = a.cpp b.cpp +CXXFLAGS_NO_DEBUGINFO = -c +CXXFLAGS_DEBUGINFO = -c -g + +all: main + +main: a.o b.o + $(CXX) a.o b.o -o main $(LDFLAGS) + +a.o: a.cpp + $(CXX) $(SRCDIR)/a.cpp $(CXXFLAGS_NO_DEBUGINFO) -o a.o + +b.o: b.cpp + $(CXX) $(SRCDIR)/b.cpp $(CXXFLAGS_DEBUGINFO) -o b.o + +clean: OBJECTS += a.o b.o main + +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/operator-overload/TestOperatorOverload.py b/lldb/packages/Python/lldbsuite/test/lang/cpp/operator-overload/TestOperatorOverload.py new file mode 100644 index 00000000000..0191e08d29f --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/operator-overload/TestOperatorOverload.py @@ -0,0 +1,22 @@ +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TestOperatorOverload(TestBase): + mydir = TestBase.compute_mydir(__file__) + + def test_overload(self): + self.build() + (target, process, thread, + main_breakpoint) = lldbutil.run_to_source_breakpoint(self, + "break here", lldb.SBFileSpec("b.cpp"), exe_name = "main") + frame = thread.GetSelectedFrame() + value = frame.EvaluateExpression("x == nil") + self.assertTrue(str(value.GetError()) + .find("comparison between NULL and non-pointer ('Tinky' and NULL)") + != -1) + self.assertTrue(str(value.GetError()) + .find("invalid operands to binary expression ('Tinky' and 'long')") + != -1) + self.assertFalse(value.GetError().Success()) diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/operator-overload/a.cpp b/lldb/packages/Python/lldbsuite/test/lang/cpp/operator-overload/a.cpp new file mode 100644 index 00000000000..77b2f6ace82 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/operator-overload/a.cpp @@ -0,0 +1,9 @@ +class Patatino { +public: + double _blah; + Patatino(int blah) : _blah(blah) {} +}; + +bool operator==(const Patatino& a, const Patatino& b) { + return a._blah < b._blah; +} diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/operator-overload/b.cpp b/lldb/packages/Python/lldbsuite/test/lang/cpp/operator-overload/b.cpp new file mode 100644 index 00000000000..c0eb29bb79f --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/operator-overload/b.cpp @@ -0,0 +1,10 @@ +class Tinky { +public: + int _meh; + Tinky(int meh) : _meh(meh) {} +}; + +int main(void) { + Tinky x(12); + return 0; // break here +} |