From 6bce74d590343ad39dc5b2beaeadfcfc2d201462 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Sat, 27 Feb 2010 03:01:12 -0500 Subject: Add initial support for new-style classes --- test_gdb.py | 44 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) (limited to 'test_gdb.py') 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'', 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'', 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'', 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'', 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 -- cgit