From 3ca3848464e5b34558046d3e4ad9a3f33a3ca5fa Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Thu, 16 Aug 2012 15:10:07 +0000 Subject: [PATCH] Implemented missing runtime tests git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13635 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/common.mk | 1 + .../test-suite/doxygen_tricky_constructs.i | 64 ++++++----- .../java/doxygen_basic_notranslate_runme.java | 100 +++++++++++++++++ .../java/doxygen_tricky_constructs_runme.java | 105 ++++++++++++++++++ .../python/doxygen_tricky_constructs_runme.py | 54 +++++++++ 5 files changed, 295 insertions(+), 29 deletions(-) create mode 100644 Examples/test-suite/java/doxygen_basic_notranslate_runme.java create mode 100644 Examples/test-suite/java/doxygen_tricky_constructs_runme.java create mode 100644 Examples/test-suite/python/doxygen_tricky_constructs_runme.py diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index e7f757f0e..729d04d66 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -193,6 +193,7 @@ CPP_TEST_CASES += \ doxygen_translate \ doxygen_translate_all_tags \ doxygen_translate_links \ + doxygen_tricky_constructs \ dynamic_cast \ empty \ enum_rename \ diff --git a/Examples/test-suite/doxygen_tricky_constructs.i b/Examples/test-suite/doxygen_tricky_constructs.i index 96b1dfae3..44cbb0426 100644 --- a/Examples/test-suite/doxygen_tricky_constructs.i +++ b/Examples/test-suite/doxygen_tricky_constructs.i @@ -5,8 +5,8 @@ %inline %{ - # Bug 1: Tag '@endink' is not recognized becuse it is not - # followed by whitespace. + // Bug 1: Tag '@endink' is not recognized becuse it is not + // followed by whitespace. /** * Tag endlink must be recognized also when followed by nonspace charater. @@ -26,13 +26,13 @@ int g_zipCode; - # Bug 2: Paramter 'isReportSize' is missing in comment of the overload, which - # has it. This bug disappears if @endlink is follwed by a space. - # - # Bug 3: Empty line before the link is missing, - # making the link text part of parameter description. This bug appears also - # when there is ordinary text in place of the link in case of overload - # with only 2 parameters. + // Bug 2: Paramter 'isReportSize' is missing in comment of the overload, which + // has it. This bug disappears if @endlink is follwed by a space. + // + // Bug 3: Empty line before the link is missing, + // making the link text part of parameter description. This bug appears also + // when there is ordinary text in place of the link in case of overload + // with only 2 parameters. /** * Returns address of file line. * @@ -42,12 +42,14 @@ * * @link Connection::getId() @endlink
*/ - std::vector getAddress(const std::string &fileName, + void getAddress(int &fileName, int line, - bool isGetSize = false); + bool isGetSize = false) + { + } - # Bug 4: The first comment is attached to the second in Python (wrong), - # but not in Java (correct). + // Bug 4: The first comment is attached to the second in Python (wrong), + // but not in Java (correct). /** * \defgroup icFacade isystem.connect Facade * @@ -73,34 +75,38 @@ { }; - # Bug 5: Text after '\c' has no space following in Python. - # There are also to many empty lines in multiline comments in Python. - # Whitespaces are really a problem in Python (space and newlines), - # I like a parameter type added to each parameter description! - # """ - # Determines how long the isystem.connectshould wait for running - # - # instances to respond. Only one of lfWaitXXXflags from IConnect::ELaunchFlags - # - # may be specified. - # - # """ + // Bug 5: Text after '\c' has no space following in Python. + // There are also to many empty lines in multiline comments in Python. + // Whitespaces are really a problem in Python (space and newlines), + // I like a parameter type added to each parameter description! + // """ + // Determines how long the isystem.connectshould wait for running + // + // instances to respond. Only one of lfWaitXXXflags from IConnect::ELaunchFlags + // + // may be specified. + // + // """ /** * Determines how long the \c isystem.connect should wait for running * instances to respond. Only one of \c lfWaitXXX flags from IConnect::ELaunchFlags * may be specified. */ - int waitTime(long waitTime); + int waitTime(long waitTime) + { + } - # Bug 6: Text after tag \ingroup appears in Python comment (empty line in - # Java, which is acceptable): + // Bug 6: Text after tag \ingroup appears in Python comment (empty line in + // Java, which is acceptable): /** \ingroup icFacade * * This class manages connection. */ - int getConnection(); + int getConnection() + { + } %} diff --git a/Examples/test-suite/java/doxygen_basic_notranslate_runme.java b/Examples/test-suite/java/doxygen_basic_notranslate_runme.java new file mode 100644 index 000000000..711cfbb88 --- /dev/null +++ b/Examples/test-suite/java/doxygen_basic_notranslate_runme.java @@ -0,0 +1,100 @@ + +import doxygen_basic_notranslate.*; +import com.sun.javadoc.*; +import java.util.HashMap; + +public class doxygen_basic_notranslate_runme { + static { + try { + System.loadLibrary("doxygen_basic_notranslate"); + } catch (UnsatisfiedLinkError e) { + System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); + System.exit(1); + } + } + + public static void main(String argv[]) + { + /* + Here we are using internal javadoc tool, it accepts the name of the class as paramterer, + and calls the start() method of that class with parsed information. + */ + commentParser parser = new commentParser(); + com.sun.tools.javadoc.Main.execute("doxygen_basic_notranslate runtime test", + "commentParser", new String[]{"-quiet", "doxygen_basic_notranslate"}); + + HashMap wantedComments = new HashMap(); + wantedComments.put("doxygen_basic_notranslate.doxygen_basic_notranslate.function3(int)", + " \n" + + " A test for overloaded functions\n" + + " This is function \\b one\n" + + " \n" + + ""); + wantedComments.put("doxygen_basic_notranslate.doxygen_basic_notranslate.function4()", + " \n" + + " A test of some mixed tag usage\n" + + " \\if CONDITION\n" + + " This \\a code fragment shows us something \\.\n" + + " \\par Minuses:\n" + + " \\arg it's senseless\n" + + " \\arg it's stupid\n" + + " \\arg it's null\n" + + " \n" + + " \\warning This may not work as expected\n" + + " \n" + + " \\code\n" + + " int main() { while(true); }\n" + + " \\endcode\n" + + " \\endif\n" + + " \n" + + ""); + wantedComments.put("doxygen_basic_notranslate.doxygen_basic_notranslate.function()", + " \n" + + " \\brief\n" + + " Brief description.\n" + + " \n" + + " The comment text\n" + + " \\author Some author\n" + + " \\return Some number\n" + + " \\sa function2\n" + + " \n" + + ""); + wantedComments.put("doxygen_basic_notranslate.doxygen_basic_notranslate.function5(int)", + " This is a post comment. \n" + + ""); + wantedComments.put("doxygen_basic_notranslate.doxygen_basic_notranslate.function7(doxygen_basic_notranslate.SWIGTYPE_p_p_p_Shape)", + " \n" + + " Test for a parameter with difficult type\n" + + " (mostly for python)\n" + + " @param a Very strange param\n" + + " \n" + + ""); + wantedComments.put("doxygen_basic_notranslate.doxygen_basic_notranslate.function3(int, int)", + " \n" + + " A test for overloaded functions\n" + + " This is function \\b two\n" + + " \n" + + ""); + wantedComments.put("doxygen_basic_notranslate.doxygen_basic_notranslate.function6(int)", + " \n" + + " Test for default args\n" + + " @param a Some parameter, default is 42\n" + + " \n" + + ""); + wantedComments.put("doxygen_basic_notranslate.doxygen_basic_notranslate.function6()", + " \n" + + " Test for default args\n" + + " @param a Some parameter, default is 42\n" + + " \n" + + ""); + wantedComments.put("doxygen_basic_notranslate.doxygen_basic_notranslate.function2()", + " \n" + + " A test of a very very very very very very very very very very very very very very very very\n" + + " very very very very very long comment string.\n" + + " \n" + + ""); + + // and ask the parser to check comments for us + System.exit(parser.check(wantedComments)); + } +} \ No newline at end of file diff --git a/Examples/test-suite/java/doxygen_tricky_constructs_runme.java b/Examples/test-suite/java/doxygen_tricky_constructs_runme.java new file mode 100644 index 000000000..bb4f69839 --- /dev/null +++ b/Examples/test-suite/java/doxygen_tricky_constructs_runme.java @@ -0,0 +1,105 @@ + +import doxygen_tricky_constructs.*; +import com.sun.javadoc.*; +import java.util.HashMap; + +public class doxygen_tricky_constructs_runme { + static { + try { + System.loadLibrary("doxygen_tricky_constructs"); + } catch (UnsatisfiedLinkError e) { + System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); + System.exit(1); + } + } + + public static void main(String argv[]) + { + /* + Here we are using internal javadoc tool, it accepts the name of the class as paramterer, + and calls the start() method of that class with parsed information. + */ + commentParser parser = new commentParser(); + com.sun.tools.javadoc.Main.execute("doxygen_tricky_constructs runtime test", + "commentParser", new String[]{"-quiet", "doxygen_tricky_constructs"}); + + HashMap wantedComments = new HashMap(); + + wantedComments.put("doxygen_tricky_constructs.doxygen_tricky_constructs.getConnection()", + " \n" + + " \n" + + " This class manages connection. \n" + + " \n" + + ""); + wantedComments.put("doxygen_tricky_constructs.doxygen_tricky_constructs.getAddress(doxygen_tricky_constructs.SWIGTYPE_p_int, int)", + " Returns address of file line. \n" + + " \n" + + " @param fileName name of the file, where the source line is located \n" + + " @param line line number \n" + + " {@link Connection::getId() }
\n" + + " \n" + + ""); + wantedComments.put("doxygen_tricky_constructs.doxygen_tricky_constructs.getG_zipCode()", + " Tag endlink must be recognized also when it is the last token \n" + + " in the commment. \n" + + " \n" + + " {@link Connection::getId() }
\n" + + " {@link debugIdeTraceProfilerCoverageSample.py Python example. }\n" + + " \n" + + ""); + wantedComments.put("doxygen_tricky_constructs.doxygen_tricky_constructs.setG_zipCode(int)", + " Tag endlink must be recognized also when it is the last token \n" + + " in the commment. \n" + + " \n" + + " {@link Connection::getId() }
\n" + + " {@link debugIdeTraceProfilerCoverageSample.py Python example. }\n" + + " \n" + + ""); + wantedComments.put("doxygen_tricky_constructs.doxygen_tricky_constructs.getG_counter()", + " Tag endlink must be recognized also when followed by nonspace charater. \n" + + " \n" + + " {@link Connection::getId() }
\n" + + " \n" + + ""); + wantedComments.put("doxygen_tricky_constructs.doxygen_tricky_constructs.waitTime(int)", + " Determines how long the isystem.connect should wait for running \n" + + " instances to respond. Only one of lfWaitXXX flags from IConnect::ELaunchFlags \n" + + " may be specified. \n" + + " \n" + + ""); + wantedComments.put("doxygen_tricky_constructs.CConnectionConfig", + " This class contains information for connection to winIDEA. Its methods \n" + + " return reference to self, so we can use it like this: \n" + + "
 \n" +
+    		" CConnectionConfig config = new CConnectionConfig(); \n" +
+    		" config.discoveryPort(5534).dllPath(\"C: \\ yWinIDEA \\ onnect.dll\").id(\"main\"); \n" +
+    		" 
\n" + + " \n" + + " All parameters are optional. Set only what is required, default values are \n" + + " used for unspecified parameters. \n" + + "

\n" + + " \n" + + " {@link advancedWinIDEALaunching.py Python example. }
\n" + + " \n" + + ""); + wantedComments.put("doxygen_tricky_constructs.doxygen_tricky_constructs.getAddress(doxygen_tricky_constructs.SWIGTYPE_p_int, int, boolean)", + " Returns address of file line. \n" + + " \n" + + " @param fileName name of the file, where the source line is located \n" + + " @param line line number \n" + + " @param isGetSize if set, for every object location both address and size are returned \n" + + " \n" + + " {@link Connection::getId() }
\n" + + " \n" + + ""); + wantedComments.put("doxygen_tricky_constructs.doxygen_tricky_constructs.setG_counter(char)", + " Tag endlink must be recognized also when followed by nonspace charater. \n" + + " \n" + + " {@link Connection::getId() }
\n" + + " \n" + + ""); + + // and ask the parser to check comments for us + System.exit(parser.check(wantedComments)); + } +} \ No newline at end of file diff --git a/Examples/test-suite/python/doxygen_tricky_constructs_runme.py b/Examples/test-suite/python/doxygen_tricky_constructs_runme.py new file mode 100644 index 000000000..156a279b7 --- /dev/null +++ b/Examples/test-suite/python/doxygen_tricky_constructs_runme.py @@ -0,0 +1,54 @@ +#!/usr/bin/python + +import doxygen_tricky_constructs +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_tricky_constructs.getAddress.__doc__, '' +'Returns address of file line.' +'' +' Arguments:' +' fileName (int &) -- name of the file, where the source' +' line is located' +' line (int) -- line number' +' isGetSize (bool) -- if set, for every object location' +' both address and size are returned' +'' +'' +' Connection::getId()
' +) +check(doxygen_tricky_constructs.CConnectionConfig.__doc__, '' +' This class contains information for connection to winIDEA. Its methods' +' return reference to self, so we can use it like this:' +'

'
+'    CConnectionConfig config = new CConnectionConfig();'
+'    config.discoveryPort(5534).dllPath("C: \yWinIDEA \onnect.dll").id("main");'
+'    
' +'' +' All parameters are optional. Set only what is required, default values are' +' used for unspecified parameters.' +'

' +'' +' advancedWinIDEALaunching.py Python example.
' +'' +) +check(doxygen_tricky_constructs.waitTime.__doc__, '' +' Determines how long the isystem.connect should wait for running' +' instances to respond. Only one of lfWaitXXX flags from IConnect::ELaunchFlags' +' may be specified.' +) +check(doxygen_tricky_constructs.getConnection.__doc__, '' +'This class manages connection.' +) \ No newline at end of file