* Added .hgignore file
* Incorporated a user patch for the do{}while statement, and added some tests of my own to verify it works
diff --git a/tests/test_c_parser.py b/tests/test_c_parser.py
index d57d8ee..20667ac 100644
--- a/tests/test_c_parser.py
+++ b/tests/test_c_parser.py
@@ -860,7 +860,11 @@
'preorder' appearance) in the chunk of code is as
given.
"""
- parsed = self.parse(code)
+ if isinstance(code, str):
+ parsed = self.parse(code)
+ else:
+ parsed = code
+
cv = self.ConstantVisitor()
cv.visit(parsed)
self.assertEqual(cv.values, constants)
@@ -972,6 +976,25 @@
# declarations don't count
self.assert_num_ID_refs(ps2, 'hash', 6)
self.assert_num_ID_refs(ps2, 'i', 4)
+
+ s3 = r'''
+ void x(void) {
+ int a, b;
+ if (a < b)
+ do {
+ a = 0;
+ } while (0);
+ else if (a == b) {
+ a = 1;
+ }
+ }
+ '''
+
+ ps3 = self.parse(s3)
+ self.assert_num_klass_nodes(ps3, DoWhile, 1)
+ self.assert_num_ID_refs(ps3, 'a', 4)
+ self.assert_all_Constants(ps3, ['0', '0', '1'])
+
def test_whole_file(self):
# See how pycparser handles a whole, real C file.