diff options
author | David Malcolm <dmalcolm@redhat.com> | 2010-02-27 03:01:12 -0500 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2010-02-27 03:01:12 -0500 |
commit | 6bce74d590343ad39dc5b2beaeadfcfc2d201462 (patch) | |
tree | 1796b9b8bc1b942a374c39c2ad27013bd11c880e /test_gdb.py | |
parent | e0fef4a512f975c30df50f68f24e7c5410ec1fe6 (diff) | |
download | libpython-6bce74d590343ad39dc5b2beaeadfcfc2d201462.tar.gz libpython-6bce74d590343ad39dc5b2beaeadfcfc2d201462.tar.xz libpython-6bce74d590343ad39dc5b2beaeadfcfc2d201462.zip |
Add initial support for new-style classes
Diffstat (limited to 'test_gdb.py')
-rw-r--r-- | test_gdb.py | 44 |
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 |