From 8a683e42d0341388a46b964572d46ecf40a69796 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Mon, 23 Jul 2012 13:50:27 +0000 Subject: [PATCH] Fixed and updated all doxygen python tests git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13346 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../python/doxygen_basic_translate_runme.py | 62 ++++ .../python/doxygen_parsing_runme.py | 56 +-- .../doxygen_translate_all_tags_runme.py | 320 ++++++++++++++++++ .../python/doxygen_translate_runme.py | 148 ++++++++ 4 files changed, 562 insertions(+), 24 deletions(-) create mode 100644 Examples/test-suite/python/doxygen_basic_translate_runme.py create mode 100644 Examples/test-suite/python/doxygen_translate_all_tags_runme.py create mode 100644 Examples/test-suite/python/doxygen_translate_runme.py diff --git a/Examples/test-suite/python/doxygen_basic_translate_runme.py b/Examples/test-suite/python/doxygen_basic_translate_runme.py new file mode 100644 index 000000000..95596c1f3 --- /dev/null +++ b/Examples/test-suite/python/doxygen_basic_translate_runme.py @@ -0,0 +1,62 @@ +#!/usr/bin/python + +import doxygen_basic_translate +import string +import sys + +def check(got, expected): + #if got is Null + # raise RuntimeError('Expected comment string\n') + gotStr = string.replace(got, ' ', '') + gotStr = string.replace(gotStr, '\n', '') + gotStr = string.replace(gotStr, '\t', '') + expectedStr = string.replace(expected, ' ', '') + expectedStr = string.replace(expectedStr, '\n', '') + expectedStr = string.replace(expectedStr, '\t', '') + if not gotStr == expectedStr: + raise RuntimeError("Expected: [" + str(expected) + "]\n" + "Got : [" + str(got) + "]\n") + +check(doxygen_basic_translate.function.__doc__, '' +' Brief description.\n' +' The comment text\n' +' Authors:\n' +' Some author\n' +' Return:\n' +' Some number\n' +' See also:\n' +' function2\n' +) +check(doxygen_basic_translate.function2.__doc__, '' +' A test of a very very very very very very very very very very very' +' very very very very very' +' very very very very very long comment' +' string.' +) +check(doxygen_basic_translate.function3.__doc__, '' +' ----------------------------------------------------------------\n' +' Overload 1:\n' +' ----------------------------------------------------------------\n' +' A test for overloaded functions\n' +' This is function __one__\n' +' ----------------------------------------------------------------\n' +' Overload 2:\n' +' ----------------------------------------------------------------\n' +' A test for overloaded functions\n' +' This is function __two__\n' +) +check(doxygen_basic_translate.function4.__doc__, '' +' A test of some mixed tag usage\n' +' If: CONDITION {\n' +' This _code_fragment shows us something .\n' +' Title: Minuses:\n' +' -it\'s senseless\n' +' -it\'s stupid\n' +' -it\'s null\n' +' Warning:\n' +' This may not work as expected\n' +' int main() { while(true); }\n' +' }' +) +check(doxygen_basic_translate.function5.__doc__, '' +' Test for default args' +) \ No newline at end of file diff --git a/Examples/test-suite/python/doxygen_parsing_runme.py b/Examples/test-suite/python/doxygen_parsing_runme.py index b814a68ed..cb22bb369 100644 --- a/Examples/test-suite/python/doxygen_parsing_runme.py +++ b/Examples/test-suite/python/doxygen_parsing_runme.py @@ -1,39 +1,47 @@ #!/usr/bin/python import doxygen_parsing +import string import sys -import re def check(got, expected): - if not re.match(str(expected), str(got)): - raise RuntimeError("\n" + "Expected: [" + str(expected) + "]\n" + "Got : [" + str(got) + "]") + #if got is Null + # raise RuntimeError('Expected comment string\n') + gotStr = string.replace(got, ' ', '') + gotStr = string.replace(gotStr, '\n', '') + gotStr = string.replace(gotStr, '\t', '') + expectedStr = string.replace(expected, ' ', '') + expectedStr = string.replace(expectedStr, '\n', '') + expectedStr = string.replace(expectedStr, '\t', '') + if not gotStr == expectedStr: + raise RuntimeError("Expected: [" + str(expected) + "]\n" + "Got : [" + str(got) + "]\n") -check(doxygen_parsing.someFunction.__doc__, '\s+The function comment\s+') -check(doxygen_parsing.SomeClass.__doc__, '\s+The class comment\s+') -check(doxygen_parsing.SomeStruct.__doc__, '\s+The struct comment\s+') -check(doxygen_parsing.SomeAnotherClass.classMethod.__doc__, '\s+The class method comment\s+') +check(doxygen_parsing.someFunction.__doc__, 'The function comment') +check(doxygen_parsing.SomeClass.__doc__, 'The class comment') +check(doxygen_parsing.SomeStruct.__doc__, 'The struct comment') +check(doxygen_parsing.SomeAnotherClass.classMethod.__doc__, 'The class method comment') check(doxygen_parsing.SomeAnotherClass.classMethodExtended.__doc__, '' -'\s+The class method with parameter' -'\s+Arguments:\s+' -'a \(int\)\s+-- Parameter a\s+' -'b \(int\)\s+-- Parameter b\s+' +'The class method with parameter\n' +'Arguments:\n' +'a (int) -- Parameter a\n' +'b (int) -- Parameter b\n' ) check(doxygen_parsing.SomeAnotherClass.classMethodExtended2.__doc__, '' -'\s+The class method with parameter' -'\s+Arguments:\s+' -'a \(int\)\s+-- Parameter a\s+' -'b \(int\)\s+-- Parameter b\s+' +'The class method with parameter\n' +'Arguments:\n' +'a (int)-- Parameter a\n' +'b (int)-- Parameter b\n' ) -check(doxygen_parsing.SomeAnotherStruct.structMethod.__doc__, '\s+The struct method comment\s+') +check(doxygen_parsing.SomeAnotherStruct.structMethod.__doc__, 'The struct method comment') check(doxygen_parsing.SomeAnotherStruct.structMethodExtended.__doc__, '' -'\s+The struct method with parameter' -'\s+Arguments:\s+' -'a \(int\)\s+-- Parameter a\s+' -'b \(int\)\s+-- Parameter b\s+' +'The struct method with parameter\n' +'Arguments:\n' +'a (int)-- Parameter a\n' +'b (int)-- Parameter b\n' ) check(doxygen_parsing.SomeAnotherStruct.structMethodExtended2.__doc__, '' -'\s+The struct method with parameter' -'\s+Arguments:\s+' -'a \(int\)\s+-- Parameter a\s+' -'b \(int\)\s+-- Parameter b\s+' +'The struct method with parameter\n' +'Arguments:\n' +'a (int)-- Parameter a\n' +'b (int)-- Parameter b\n' ) \ No newline at end of file diff --git a/Examples/test-suite/python/doxygen_translate_all_tags_runme.py b/Examples/test-suite/python/doxygen_translate_all_tags_runme.py new file mode 100644 index 000000000..768ccf1ba --- /dev/null +++ b/Examples/test-suite/python/doxygen_translate_all_tags_runme.py @@ -0,0 +1,320 @@ +#!/usr/bin/python + +import doxygen_translate_all_tags +import string +import sys + +def check(got, expected): + #if got is Null + # raise RuntimeError('Expected comment string\n') + gotStr = string.replace(got, ' ', '') + gotStr = string.replace(gotStr, '\n', '') + gotStr = string.replace(gotStr, '\t', '') + expectedStr = string.replace(expected, ' ', '') + expectedStr = string.replace(expectedStr, '\n', '') + expectedStr = string.replace(expectedStr, '\t', '') + if not gotStr == expectedStr: + raise RuntimeError("Expected: [" + str(expected) + "]\n" + "Got : [" + str(got) + "]\n") + +check(doxygen_translate_all_tags.function.__doc__, '' +' _Hello_' +'' +' SomeLatexIndex ' +'' +' someGroupSome title ' +'' +' theAnchor' +'' +' -some list item ' +'' +' This is attention! ' +' You were warned! ' +'' +' Authors:' +' lots of them ' +'' +' Zubr ' +'' +' __boldword__' +'' +' Some brief description, ' +' extended to many lines. ' +'' +' Not everything works right now... ' +'' +' codeword' +'' +' someCategoryheaderFile.hheaderName' +'' +' \'citationword\'' +'' +' someClassheaderFile.hheaderName' +'' +' some test code ' +'' +' Conditional comment: SOMECONDITION' +' Some conditional comment ' +' End of conditional comment.' +'' +' someClass::someMethod' +'' +' someClass::someMethod2' +'' +' someClass::someMethod3' +'' +' Copyright:' +' some copyright ' +'' +' 1970 - 2012 ' +'' +' someDefine' +'' +' someGroupSome titles ' +'' +' Deprecated:' +' Now use another function ' +'' +' This is very large ' +' and detailed description of some thing ' +'' +' /somePath/someFolder' +'' +' someFile.h' +'' +' digraph example { ' +' node [shape=record, fontname=Helvetica, fontsize=10]; ' +'' +' b [ label="class B" URL="\ref B"]; ' +' c [ label="class C" URL="\ref C"]; ' +' b -> c [ arrowhead="open", style="dashed" ]; ' +' } ' +'' +'' +' dotFile.dotThe caption' +'' +' _italicword_' +'' +' emphazedWord' +'' +' someEnum' +'' +' Example:' +' someFile.txt' +' Some details on using the example ' +'' +' Throws:' +' SuperError' +'' +' someOtherFunction' +'' +' file.h' +'' +' someFn ' +'' +' someHeader.hHeader name' +'' +' htmlFile.htm' +'' +' This will only appear in hmtl ' +'' +' If: ANOTHERCONDITION {' +' First part of comment ' +' If: SECONDCONDITION {' +' Nested condition text ' +' }Else if: THIRDCONDITION {' +' The third condition text ' +' }Else: {The last text block ' +' }' +' }Else: {Second part of comment ' +' If: CONDITION {' +' Second part extended ' +' }' +' }' +'' +' If not: SOMECONDITION {' +' This is printed if not ' +' }' +'' +' Image: htmltestImage.bmpHello, world!asd=10qwe' +'' +' someFunction' +'' +' header.h' +'' +' header2.h' +'' +' someGroupanotherGroup' +'' +' Some text ' +' describing invariant. ' +'' +' someInterfacesomeHeader.hHeader name' +'' +' This will only appear in LATeX ' +'' +' ' +'' +' example ' +'' +' someMember Some description follows ' +'' +' Sometitle ' +'' +' This will only appear in man ' +'' +' someThing' +'' +' Sender,Receiver; ' +' Sender->Receiver [label="Command()", URL="\ref ' +' Receiver::Command()"]; ' +' Sender<-Receiver [label="Ack()", URL="\ref ' +' Ack()", ID="1"]; ' +'' +' mscFile.mscThe caption' +'' +' someHeader.h ' +'' +' someNamespace' +'' +' Notes:' +' Here ' +' is the note! ' +'' +' This is an overloaded member function, provided for convenience.' +' It differs from the above function only in what argument(s) it accepts.' +'' +' someword' +'' +' superPackage' +'' +' somePageThe title ' +'' +' Title: The paragraph title ' +' The paragraph text. ' +' Maybe even multiline ' +'' +' someParagraphParagraph title ' +'' +' Arguments:' +' a (int) -- the first param ' +'' +' Some description ' +'' +' Some description ' +'' +' someVar ' +'' +' someProtocolheader.hHeader name' +'' +' someAnchor' +'' +' toSomething' +'' +' toSomethingElse' +'' +' someName' +'' +' someName' +'' +' Remarks:' +' Some remark text ' +'' +' Another remarks section ' +'' +' Return:' +' Whatever ' +'' +' it ' +'' +' may return ' +'' +' someValueSome description ' +'' +'' +' This will only appear in RTF ' +'' +'' +' See also:' +' someOtherMethod ' +'' +' someSectionSome title ' +'' +' function ' +'' +' Same as ' +' brief description ' +'' +'' +'' +' Since:' +' version 0.0.0.1 ' +'' +' somePattern ' +'' +' someLine ' +'' +' example.hSome snippet ' +'' +' someStruct' +'' +' someSubpageSome description' +'' +' someSubsectionSome title ' +'' +' someSubsectionSome title ' +'' +'' +'' +' Some ' +' description of the ' +' test case ' +'' +' Throws:' +' superException' +'' +' RuntimeError' +'' +' TODO:' +' Some very important task ' +'' +' Arguments:' +' b (float) -- B is mentioned again... ' +'' +' someTypedef ' +'' +' someUnion' +'' +' somePattern ' +'' +' someVar ' +'' +'' +' very long ' +' text with tags ' +'' +'' +' someFile.h' +'' +' Version:' +' 0.0.0.2 ' +'' +' Warning:' +' This is senseless! ' +'' +' someGroupSome title ' +'' +'' +' This will only appear in XML ' +'' +'' +' Here goes test of symbols: ' +' $@\&~<>#%".::' +'' +' And here goes simple text ' +) \ No newline at end of file diff --git a/Examples/test-suite/python/doxygen_translate_runme.py b/Examples/test-suite/python/doxygen_translate_runme.py new file mode 100644 index 000000000..61e5f5398 --- /dev/null +++ b/Examples/test-suite/python/doxygen_translate_runme.py @@ -0,0 +1,148 @@ +#!/usr/bin/python + +import doxygen_translate +import string +import sys + +def check(got, expected): + #if got is Null + # raise RuntimeError('Expected comment string\n') + gotStr = string.replace(got, ' ', '') + gotStr = string.replace(gotStr, '\n', '') + gotStr = string.replace(gotStr, '\t', '') + expectedStr = string.replace(expected, ' ', '') + expectedStr = string.replace(expectedStr, '\n', '') + expectedStr = string.replace(expectedStr, '\t', '') + if not gotStr == expectedStr: + raise RuntimeError("Expected: [" + str(expected) + "]\n" + "Got : [" + str(got) + "]\n") + +check(doxygen_translate.function.__doc__, '' +' _Hello_' +'' +' -some list item ' +'' +' Authors:' +' lots of them ' +'' +' Zubr ' +'' +' __boldword__' +'' +' codeword' +'' +' \'citationword\'' +'' +' some test code ' +'' +' Conditional comment: SOMECONDITION' +' Some conditional comment ' +' End of conditional comment.' +'' +' Copyright:' +' some copyright ' +'' +' Deprecated:' +' Now use another function ' +'' +' _italicword_' +'' +' Example:' +' someFile.txt' +' Some details on using the example ' +'' +' Throws:' +' SuperError' +'' +' If: ANOTHERCONDITION {' +' First part of comment ' +' If: SECONDCONDITION {' +' Nested condition text ' +' }Else if: THIRDCONDITION {' +' The third condition text ' +' }Else: {The last text block ' +' }' +' }Else: {Second part of comment ' +' If: CONDITION {' +' Second part extended ' +' }' +' }' +'' +' If not: SOMECONDITION {' +' This is printed if not ' +' }' +'' +' Image: htmltestImage.bmpHello, world!asd=10qwe' +'' +' ' +'' +' someMember Some description follows ' +'' +' Notes:' +' Here ' +' is the note! ' +'' +' This is an overloaded member function, provided for convenience.' +' It differs from the above function only in what argument(s) it accepts.' +'' +' someword' +'' +' superPackage' +'' +' Title: The paragraph title ' +' The paragraph text. ' +' Maybe even multiline ' +'' +' Arguments:' +' a (int) -- the first param ' +'' +' Remarks:' +' Some remark text ' +'' +' Another remarks section ' +'' +' Return:' +' Whatever ' +'' +' it ' +'' +' may return ' +'' +' See also:' +' someOtherMethod ' +'' +' function ' +'' +' Since:' +' version 0.0.0.1 ' +'' +' Throws:' +' superException' +'' +' RuntimeError' +'' +' TODO:' +' Some very important task ' +'' +' Arguments:' +' b (float) -- B is mentioned again... ' +'' +' very long ' +' text with tags ' +'' +' Version:' +' 0.0.0.2 ' +'' +' Warning:' +' This is senseless! ' +'' +' Here goes test of symbols: ' +' $@\&~<>#%".::' +'' +' And here goes simple text ' +) \ No newline at end of file