summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEli Bendersky <eliben@gmail.com>2014-03-15 14:06:00 -0700
committerEli Bendersky <eliben@gmail.com>2014-03-15 14:06:00 -0700
commit8e5d3a9d24ab8ffcfb0bded2ba413635f130faa6 (patch)
tree1c3d1215107681ab3e252c8564131cd94d60a43d /tests
parente54a9a960d04bd48d74425d0a0ac42617d7bf023 (diff)
downloadpycparser-8e5d3a9d24ab8ffcfb0bded2ba413635f130faa6.tar.gz
Fix issue #28: coord for 'for' loops
Diffstat (limited to 'tests')
-rw-r--r--tests/test_c_parser.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/test_c_parser.py b/tests/test_c_parser.py
index f6bf0bd..d617ddd 100644
--- a/tests/test_c_parser.py
+++ b/tests/test_c_parser.py
@@ -210,6 +210,19 @@ class TestCParser_fundamentals(TestCParser_base):
f6 = self.parse(t6, filename='z.c')
self.assert_coord(self.parse(t6).ext[0].decl.type.args.params[1], 3)
+ def test_forloop_coord(self):
+ t = '''\
+ void foo() {
+ for(int z=0; z<4;
+ z++){}
+ }
+ '''
+ s = self.parse(t, filename='f.c')
+ forloop = s.ext[0].body.block_items[0]
+ self.assert_coord(forloop.init, 2, 'f.c')
+ self.assert_coord(forloop.cond, 2, 'f.c')
+ self.assert_coord(forloop.next, 3, 'f.c')
+
def test_simple_decls(self):
self.assertEqual(self.get_decl('int a;'),
['Decl', 'a', ['TypeDecl', ['IdentifierType', ['int']]]])