summaryrefslogtreecommitdiff
path: root/tests/scanner/annotationparser/test_patterns.py
diff options
context:
space:
mode:
authorDieter Verfaillie <dieterv@optionexplicit.be>2013-08-21 12:19:40 +0200
committerDieter Verfaillie <dieterv@optionexplicit.be>2013-10-08 20:56:07 +0200
commit07ad34a094cb00aef16250dfbf05d6eef05c3aff (patch)
tree547d8776e7994d106e1fbb5bf6eaeb2b713630fa /tests/scanner/annotationparser/test_patterns.py
parent3177c9868cc5daab1c7915c27e19f7236bb338df (diff)
downloadgobject-introspection-07ad34a094cb00aef16250dfbf05d6eef05c3aff.tar.gz
giscanner: store code before and after comment block
so we can later use them to re-write source files containing broken GTK-Doc comment blocks where /** is preceded by and/or */ is followed by code...
Diffstat (limited to 'tests/scanner/annotationparser/test_patterns.py')
-rw-r--r--tests/scanner/annotationparser/test_patterns.py157
1 files changed, 124 insertions, 33 deletions
diff --git a/tests/scanner/annotationparser/test_patterns.py b/tests/scanner/annotationparser/test_patterns.py
index 023f61f6..ce82cf90 100644
--- a/tests/scanner/annotationparser/test_patterns.py
+++ b/tests/scanner/annotationparser/test_patterns.py
@@ -31,13 +31,132 @@ against the expected output.
'''
-from giscanner.annotationparser import (SECTION_RE, SYMBOL_RE, PROPERTY_RE,
+from giscanner.annotationparser import (COMMENT_BLOCK_START_RE, COMMENT_BLOCK_END_RE,
+ SECTION_RE, SYMBOL_RE, PROPERTY_RE,
SIGNAL_RE, PARAMETER_RE, TAG_RE,
- TAG_VALUE_VERSION_RE, TAG_VALUE_STABILITY_RE,
- COMMENT_END_RE)
+ TAG_VALUE_VERSION_RE, TAG_VALUE_STABILITY_RE)
from unittest import (TestCase, main)
+comment_start_tests = [
+ (COMMENT_BLOCK_START_RE, '/**',
+ {'code': '',
+ 'token': '/**',
+ 'comment': ''}),
+ (COMMENT_BLOCK_START_RE, ' /**',
+ {'code': '',
+ 'token': '/**',
+ 'comment': ''}),
+ (COMMENT_BLOCK_START_RE, ' /** ',
+ {'code': '',
+ 'token': '/**',
+ 'comment': ''}),
+ (COMMENT_BLOCK_START_RE, 'xyz /** ',
+ {'code': 'xyz',
+ 'token': '/**',
+ 'comment': ''}),
+ (COMMENT_BLOCK_START_RE, ' xyz /** ',
+ {'code': ' xyz',
+ 'token': '/**',
+ 'comment': ''}),
+ (COMMENT_BLOCK_START_RE, '/** xyz',
+ {'code': '',
+ 'token': '/**',
+ 'comment': 'xyz'}),
+ (COMMENT_BLOCK_START_RE, ' /**xyz',
+ {'code': '',
+ 'token': '/**',
+ 'comment': 'xyz'}),
+ (COMMENT_BLOCK_START_RE, ' /** xyz',
+ {'code': '',
+ 'token': '/**',
+ 'comment': 'xyz'}),
+ (COMMENT_BLOCK_START_RE, '/***',
+ None),
+ (COMMENT_BLOCK_START_RE, ' /***',
+ None),
+ (COMMENT_BLOCK_START_RE, ' /*** ',
+ None),
+ (COMMENT_BLOCK_START_RE, '/*** xyz',
+ None),
+ (COMMENT_BLOCK_START_RE, '/***** xyz',
+ None),
+ (COMMENT_BLOCK_START_RE, ' /*****xyz',
+ None),
+]
+
+
+comment_end_tests = [
+ (COMMENT_BLOCK_END_RE, '*/',
+ {'comment': '',
+ 'token': '*/',
+ 'code': ''}),
+ (COMMENT_BLOCK_END_RE, ' */',
+ {'comment': '',
+ 'token': '*/',
+ 'code': ''}),
+ (COMMENT_BLOCK_END_RE, ' */ ',
+ {'comment': '',
+ 'token': '*/',
+ 'code': ''}),
+ (COMMENT_BLOCK_END_RE, '*/xyz',
+ {'comment': '',
+ 'token': '*/',
+ 'code': 'xyz'}),
+ (COMMENT_BLOCK_END_RE, ' */xyz',
+ {'comment': '',
+ 'token': '*/',
+ 'code': 'xyz'}),
+ (COMMENT_BLOCK_END_RE, ' */ xyz',
+ {'comment': '',
+ 'token': '*/',
+ 'code': ' xyz'}),
+ (COMMENT_BLOCK_END_RE, '**/',
+ {'comment': '',
+ 'token': '**/',
+ 'code': ''}),
+ (COMMENT_BLOCK_END_RE, ' **/',
+ {'comment': '',
+ 'token': '**/',
+ 'code': ''}),
+ (COMMENT_BLOCK_END_RE, ' **/ ',
+ {'comment': '',
+ 'token': '**/',
+ 'code': ''}),
+ (COMMENT_BLOCK_END_RE, 'test */',
+ {'comment': 'test',
+ 'token': '*/',
+ 'code': ''}),
+ (COMMENT_BLOCK_END_RE, ' test*/',
+ {'comment': 'test',
+ 'token': '*/',
+ 'code': ''}),
+ (COMMENT_BLOCK_END_RE, 'test */ xyz',
+ {'comment': 'test',
+ 'token': '*/',
+ 'code': ' xyz'}),
+ (COMMENT_BLOCK_END_RE, ' test*/ xyz ',
+ {'comment': 'test',
+ 'token': '*/',
+ 'code': ' xyz'}),
+ (COMMENT_BLOCK_END_RE, 'test **/',
+ {'comment': 'test',
+ 'token': '**/',
+ 'code': ''}),
+ (COMMENT_BLOCK_END_RE, ' test**/',
+ {'comment': 'test',
+ 'token': '**/',
+ 'code': ''}),
+ (COMMENT_BLOCK_END_RE, 'test *****/',
+ {'comment': 'test',
+ 'token': '*****/',
+ 'code': ''}),
+ (COMMENT_BLOCK_END_RE, ' test*****/',
+ {'comment': 'test',
+ 'token': '*****/',
+ 'code': ''})]
+
+
identifier_section_tests = [
(SECTION_RE, 'TSIEOCN',
None),
@@ -571,33 +690,6 @@ tag_value_stability_tests = [
'description': 'xyz: abc'})]
-comment_end_tests = [
- (COMMENT_END_RE, '*/',
- {'description': ''}),
- (COMMENT_END_RE, ' */',
- {'description': ''}),
- (COMMENT_END_RE, ' */ ',
- {'description': ''}),
- (COMMENT_END_RE, '**/',
- {'description': ''}),
- (COMMENT_END_RE, ' **/',
- {'description': ''}),
- (COMMENT_END_RE, ' **/ ',
- {'description': ''}),
- (COMMENT_END_RE, 'test */',
- {'description': 'test'}),
- (COMMENT_END_RE, ' test*/',
- {'description': 'test'}),
- (COMMENT_END_RE, 'test **/',
- {'description': 'test'}),
- (COMMENT_END_RE, ' test**/',
- {'description': 'test'}),
- (COMMENT_END_RE, 'test *****/',
- {'description': 'test'}),
- (COMMENT_END_RE, ' test*****/',
- {'description': 'test'})]
-
-
def create_tests(tests_name, testcases):
for (index, testcase) in enumerate(testcases):
real_test_name = '%s_%03d' % (tests_name, index)
@@ -639,16 +731,15 @@ class TestProgram(TestCase):
if __name__ == '__main__':
- # Create tests from data
+ create_tests('test_comment_start', comment_start_tests)
+ create_tests('test_comment_end', comment_end_tests)
create_tests('test_identifier_section', identifier_section_tests)
create_tests('test_identifier_symbol', identifier_symbol_tests)
create_tests('test_identifier_property', identifier_property_tests)
create_tests('test_identifier_signal', identifier_signal_tests)
create_tests('test_parameter', parameter_tests)
create_tests('test_tag', tag_tests)
- create_tests('test_comment_end', comment_end_tests)
create_tests('test_tag_value_version', tag_value_version_tests)
create_tests('test_tag_value_stability', tag_value_stability_tests)
- # Run test suite
main()