summaryrefslogtreecommitdiffstats
path: root/test_gdb.py
diff options
context:
space:
mode:
Diffstat (limited to 'test_gdb.py')
-rw-r--r--test_gdb.py44
1 files changed, 41 insertions, 3 deletions
diff --git a/test_gdb.py b/test_gdb.py
index 82cef5d..a75a2b9 100644
--- a/test_gdb.py
+++ b/test_gdb.py
@@ -169,14 +169,53 @@ class DebuggerTests(unittest.TestCase):
gdb_repr, gdb_output = self.get_gdb_repr('''
class Foo:
pass
-foo = Foo();
-foo.an_int = 42;
+foo = Foo()
+foo.an_int = 42
print foo''')
# FIXME: is there an "assertMatches"; should there be?
m = re.match(r'<Foo\(an_int=42\) at remote 0x[0-9a-f]+>', gdb_repr)
self.assertTrue(m,
msg='Unexpected classic-class rendering %r' % gdb_repr)
+ def test_modern_class(self):
+ gdb_repr, gdb_output = self.get_gdb_repr('''
+class Foo(object):
+ pass
+foo = Foo()
+foo.an_int = 42
+print foo''')
+ # FIXME: is there an "assertMatches"; should there be?
+ m = re.match(r'<Foo\(an_int=42\) at remote 0x[0-9a-f]+>', gdb_repr)
+ self.assertTrue(m,
+ msg='Unexpected new-style class rendering %r' % gdb_repr)
+
+ def test_subclassing_list(self):
+ gdb_repr, gdb_output = self.get_gdb_repr('''
+class Foo(list):
+ pass
+foo = Foo()
+foo += [1, 2, 3]
+foo.an_int = 42
+print foo''')
+ # FIXME: is there an "assertMatches"; should there be?
+ m = re.match(r'<Foo\(an_int=42\) at remote 0x[0-9a-f]+>', gdb_repr)
+ self.assertTrue(m,
+ msg='Unexpected new-style class rendering %r' % gdb_repr)
+
+ def test_subclassing_tuple(self):
+ '''This should exercise the negative tp_dictoffset code in the
+ new-style class support'''
+ gdb_repr, gdb_output = self.get_gdb_repr('''
+class Foo(tuple):
+ pass
+foo = Foo((1, 2, 3))
+foo.an_int = 42
+print foo''')
+ # FIXME: is there an "assertMatches"; should there be?
+ m = re.match(r'<Foo\(an_int=42\) at remote 0x[0-9a-f]+>', gdb_repr)
+ self.assertTrue(m,
+ msg='Unexpected new-style class rendering %r' % gdb_repr)
+
def assertSane(self, source, corruption, exp_type='unknown'):
'''Run Python under gdb, corrupting variables in the inferior process
immediately before taking a backtrace.
@@ -214,7 +253,6 @@ print foo''')
'set op->ob_type->tp_name=0xDEADBEEF')
# TODO:
- # new-style classes
# frames