summaryrefslogtreecommitdiff
path: root/tests/scan.py
diff options
context:
space:
mode:
authorStefan Sauer <ensonic@users.sf.net>2019-07-24 19:12:36 +0200
committerStefan Sauer <ensonic@users.sf.net>2019-07-24 21:53:47 +0200
commitf19b91f2ae25f0fc2881e7414316d89a0678c9fb (patch)
tree7a50d4a0f1e4f97b22c0e2241e02f58097c66058 /tests/scan.py
parent2b40491bf8d37cd6766f289dd2c309f0d6a658d3 (diff)
downloadgtk-doc-f19b91f2ae25f0fc2881e7414316d89a0678c9fb.tar.gz
mkdb: fix skipping of inline function bodies
Add a bunch of tests for this. Fixes #90
Diffstat (limited to 'tests/scan.py')
-rwxr-xr-xtests/scan.py90
1 files changed, 85 insertions, 5 deletions
diff --git a/tests/scan.py b/tests/scan.py
index 98fddf7..77ddf3a 100755
--- a/tests/scan.py
+++ b/tests/scan.py
@@ -832,15 +832,95 @@ class SeparateSubSections(ScanHeaderContentTestCase):
liststr.splitlines())
+class RemoveBracedContent(ScanHeaderContentTestCase):
+
+ def test_OneLineFunctionBodyIsRemoved(self):
+ decl = textwrap.dedent("""\
+ static inline int function(int a) { return a + a; }""")
+ (skip, decl) = scan.remove_braced_content(decl)
+ self.assertEqual("static inline int function(int a);", decl)
+ self.assertEqual(skip, False)
+
+ def test_SimpleFunctionBodyIsRemoved(self):
+ decl = textwrap.dedent("""\
+ static inline int function(int a) {
+ return a + a;
+ }""")
+ (skip, decl) = scan.remove_braced_content(decl)
+ self.assertEqual("static inline int function(int a);", decl)
+ self.assertEqual(skip, False)
+
+ def test_SimpleFunctionWithNewlineBodyIsRemoved(self):
+ decl = textwrap.dedent("""\
+ static inline int function(int a)
+ {
+ return a + a;
+ }""")
+ (skip, decl) = scan.remove_braced_content(decl)
+ self.assertEqual("static inline int function(int a);", decl)
+ self.assertEqual(skip, False)
+
+ def test_NestedFunctionBodyIsRemoved(self):
+ decl = textwrap.dedent("""\
+ static inline int function(int a) {
+ if (a > 0) {
+ return a + a;
+ } else {
+ return a - a;
+ }
+ }""")
+ (skip, decl) = scan.remove_braced_content(decl)
+ self.assertEqual("static inline int function(int a);", decl)
+ self.assertEqual(skip, False)
+
+ def test_NestedFunctionWithNewlinesBodyIsRemoved(self):
+ decl = textwrap.dedent("""\
+ static inline int function(int a)
+ {
+ if (a > 0)
+ {
+ return a + a;
+ }
+ else
+ {
+ return a - a;
+ }
+ }""")
+ (skip, decl) = scan.remove_braced_content(decl)
+ self.assertEqual("static inline int function(int a);", decl)
+ self.assertEqual(skip, False)
+
+ def test_SimpleFunctionWithParenthesisBodyIsRemoved(self):
+ decl = textwrap.dedent("""\
+ static inline int
+ (function) (int a)
+ {
+ return a + a;
+ }""")
+ (skip, decl) = scan.remove_braced_content(decl)
+ self.assertEqual("static inline int\n(function) (int a);", decl)
+ self.assertEqual(skip, False)
+
+ def test_FunctionWithMultilineParamsBodyIsRemoved(self):
+ decl = textwrap.dedent("""\
+ static inline int
+ function (int a,
+ int b)
+ {
+ return a + b;
+ }""")
+ (skip, decl) = scan.remove_braced_content(decl)
+ self.assertEqual(
+ "static inline int\nfunction (int a,\n int b);", decl)
+ self.assertEqual(skip, False)
+
+
if __name__ == '__main__':
from gtkdoc import common
common.setup_logging()
unittest.main()
- # from gtkdoc import common
- # common.setup_logging()
- #
- # t = ScanHeaderContentFunctions()
+ # t = RemoveBracedContent()
# t.setUp()
- # t.test_IgnoresInternalInlineFunction()
+ # t.test_NestedFunctionBodyIsRemoved()