diff options
author | Eli Bendersky <eliben@gmail.com> | 2015-04-21 17:10:35 -0700 |
---|---|---|
committer | Eli Bendersky <eliben@gmail.com> | 2015-04-21 17:10:35 -0700 |
commit | df48f15934ab0bf4a06d8f5c35711691796e07e8 (patch) | |
tree | b6735533a5d7b2ae904c62725d4efcd43a8aa8dc | |
parent | 978ad7a61d7e1cfe77dbacb81f1690e6bb89a11b (diff) | |
download | pycparser-df48f15934ab0bf4a06d8f5c35711691796e07e8.tar.gz |
Test that weakref works on Coords too
-rw-r--r-- | tests/test_c_ast.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/test_c_ast.py b/tests/test_c_ast.py index 18fd542..bfe301a 100644 --- a/tests/test_c_ast.py +++ b/tests/test_c_ast.py @@ -6,6 +6,7 @@ import weakref sys.path.insert(0, '..') import pycparser.c_ast as c_ast +import pycparser.plyparser as plyparser class Test_c_ast(unittest.TestCase): @@ -22,13 +23,21 @@ class Test_c_ast(unittest.TestCase): self.failUnless(isinstance(b1.right, c_ast.ID)) self.assertEqual(b1.right.name, 'joe') - def test_weakref_works(self): + def test_weakref_works_on_nodes(self): c1 = c_ast.Constant(type='float', value='3.14') wr = weakref.ref(c1) cref = wr() self.assertEqual(cref.type, 'float') self.assertEqual(weakref.getweakrefcount(c1), 1) + def test_weakref_works_on_coord(self): + coord = plyparser.Coord(file='a', line=2) + wr = weakref.ref(coord) + cref = wr() + self.assertEqual(cref.line, 2) + self.assertEqual(weakref.getweakrefcount(coord), 1) + + class TestNodeVisitor(unittest.TestCase): class ConstantVisitor(c_ast.NodeVisitor): |