Fixed enum comments generation, added testcases

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13184 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Dmitry Kabak 2012-06-18 19:13:23 +00:00
commit b88de2aa89
14 changed files with 470 additions and 45 deletions

View file

@ -55,15 +55,6 @@ public:
}
};
/** Test enumeration */
enum E_TEST
{
/** the first item */
E_TEST_ONE,
E_TEST_TWO = 2, /**< the second */
E_TEST_THREE = 2+1
};
/**
* Comment for template class
*/

View file

@ -0,0 +1,15 @@
%module doxygen_parsing_enums
%inline %{
/** Test enumeration */
enum E_TEST
{
/** the first item */
E_TEST_ONE,
E_TEST_TWO = 2, /**< the second */
E_TEST_THREE = 2+1
};
%}

View file

@ -0,0 +1,7 @@
%module "doxygen_parsing_enums_proper"
// Test enum commenting using the proper enums in the target language
%include "enums.swg"
%include "doxygen_parsing_enums.i"

View file

@ -0,0 +1,6 @@
%module "doxygen_parsing_enums_simple"
// Test enum commenting using simple constants (SWIG-1.3.21 and earlier default enum wrapping for C# and Java)
%include "enumsimple.swg"
%include "doxygen_parsing_enums.i"

View file

@ -0,0 +1,8 @@
%module "doxygen_parsing_enums_typesafe"
// Test enum commenting using the typesafe enum pattern in the target language
%include "enumtypesafe.swg"
#define SWIG_TEST_NOCSCONST // For C# typesafe enums
%include "doxygen_parsing_enums.i"

View file

@ -0,0 +1,6 @@
%module "doxygen_parsing_enums_typeunsafe"
// Test enum commenting using a type unsafe enum pattern (constant integers in a class for the enum type)
%include "enumtypeunsafe.swg"
%include "doxygen_parsing_enums.i"

View file

@ -16,6 +16,10 @@ C_TEST_CASES = \
java_lib_various
CPP_TEST_CASES = \
doxygen_parsing_enums_simple \
doxygen_parsing_enums_proper \
doxygen_parsing_enums_typesafe \
doxygen_parsing_enums_typeunsafe \
enum_thorough_proper \
enum_thorough_simple \
enum_thorough_typeunsafe \

View file

@ -0,0 +1,93 @@
import doxygen_parsing_enums_proper.*;
import com.sun.javadoc.*;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Iterator;
public class doxygen_parsing_enums_proper_runme {
static {
try {
System.loadLibrary("doxygen_parsing_enums_proper");
} 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);
}
}
static HashMap<String, String> parsedComments = new HashMap<String, String>();
static HashMap<String, String> wantedComments = new HashMap<String, String>();
public static boolean start(RootDoc root) {
/*
This method is called by 'javadoc' and gets the whole parsed
java file, we get comments and store them
*/
ClassDoc[] classes = root.classes();
for (int i = 0; i < classes.length; i++) {
if (classes[i].getRawCommentText().length() > 0)
parsedComments.put(classes[i].name(), classes[i].getRawCommentText());
MethodDoc[] methods = classes[i].methods();
FieldDoc[] fields = classes[i].fields();
FieldDoc[] constants = classes[i].enumConstants();
for (int j = 0; j < constants.length; j++) {
FieldDoc f = constants[j];
if (f.getRawCommentText().length() > 0)
parsedComments.put(f.name(), f.getRawCommentText());
}
for (int j = 0; j < fields.length; j++) {
FieldDoc f = fields[j];
if (f.getRawCommentText().length() > 0)
parsedComments.put(f.name(), f.getRawCommentText());
}
for (int j = 0; j < methods.length; j++) {
MethodDoc m = methods[j];
if (m.getRawCommentText().length() > 0)
parsedComments.put(m.name(), m.getRawCommentText());
}
}
return true;
}
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.
*/
com.sun.tools.javadoc.Main.execute("doxygen_parsing_enums_proper runtime test",
"doxygen_parsing_enums_proper_runme", new String[]{"-quiet", "doxygen_parsing_enums_proper"});
wantedComments.put("E_TEST", " Test enumeration \n");
wantedComments.put("E_TEST_ONE", " the first item \n");
wantedComments.put("E_TEST_TWO", " the second \n");
int errorCount=0;
Iterator< Entry<String, String> > it = parsedComments.entrySet().iterator();
while (it.hasNext())
{
Entry<String, String> e = (Entry<String, String>) it.next();
if (!e.getValue().equals(wantedComments.get(e.getKey()))) {
System.out.println("Documentation comments for " + e.getKey() + " does not match: ");
System.out.println("\texpected:"+wantedComments.get(e.getKey()));
System.out.println("\tgot:\t"+e.getValue());
errorCount++;
}
}
if (parsedComments.size() != wantedComments.size()) {
System.out.println("Found " + (wantedComments.size()-parsedComments.size()) + " missed comment(s)!");
errorCount++;
}
System.exit(errorCount);
}
}

View file

@ -0,0 +1,93 @@
import doxygen_parsing_enums_simple.*;
import com.sun.javadoc.*;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Iterator;
public class doxygen_parsing_enums_simple_runme {
static {
try {
System.loadLibrary("doxygen_parsing_enums_simple");
} 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);
}
}
static HashMap<String, String> parsedComments = new HashMap<String, String>();
static HashMap<String, String> wantedComments = new HashMap<String, String>();
public static boolean start(RootDoc root) {
/*
This method is called by 'javadoc' and gets the whole parsed
java file, we get comments and store them
*/
ClassDoc[] classes = root.classes();
for (int i = 0; i < classes.length; i++) {
if (classes[i].getRawCommentText().length() > 0)
parsedComments.put(classes[i].name(), classes[i].getRawCommentText());
MethodDoc[] methods = classes[i].methods();
FieldDoc[] fields = classes[i].fields();
FieldDoc[] constants = classes[i].enumConstants();
for (int j = 0; j < constants.length; j++) {
FieldDoc f = constants[j];
if (f.getRawCommentText().length() > 0)
parsedComments.put(f.name(), f.getRawCommentText());
}
for (int j = 0; j < fields.length; j++) {
FieldDoc f = fields[j];
if (f.getRawCommentText().length() > 0)
parsedComments.put(f.name(), f.getRawCommentText());
}
for (int j = 0; j < methods.length; j++) {
MethodDoc m = methods[j];
if (m.getRawCommentText().length() > 0)
parsedComments.put(m.name(), m.getRawCommentText());
}
}
return true;
}
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.
*/
com.sun.tools.javadoc.Main.execute("doxygen_parsing_enums_simple runtime test",
"doxygen_parsing_enums_simple_runme", new String[]{"-quiet", "doxygen_parsing_enums_simple"});
wantedComments.put("E_TEST", " Test enumeration \n");
wantedComments.put("E_TEST_ONE", " the first item \n");
wantedComments.put("E_TEST_TWO", " the second \n");
int errorCount=0;
Iterator< Entry<String, String> > it = parsedComments.entrySet().iterator();
while (it.hasNext())
{
Entry<String, String> e = (Entry<String, String>) it.next();
if (!e.getValue().equals(wantedComments.get(e.getKey()))) {
System.out.println("Documentation comments for " + e.getKey() + " does not match: ");
System.out.println("\texpected:"+wantedComments.get(e.getKey()));
System.out.println("\tgot:\t"+e.getValue());
errorCount++;
}
}
if (parsedComments.size() != wantedComments.size()) {
System.out.println("Found " + (wantedComments.size()-parsedComments.size()) + " missed comment(s)!");
errorCount++;
}
System.exit(errorCount);
}
}

View file

@ -0,0 +1,93 @@
import doxygen_parsing_enums_typesafe.*;
import com.sun.javadoc.*;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Iterator;
public class doxygen_parsing_enums_typesafe_runme {
static {
try {
System.loadLibrary("doxygen_parsing_enums_typesafe");
} 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);
}
}
static HashMap<String, String> parsedComments = new HashMap<String, String>();
static HashMap<String, String> wantedComments = new HashMap<String, String>();
public static boolean start(RootDoc root) {
/*
This method is called by 'javadoc' and gets the whole parsed
java file, we get comments and store them
*/
ClassDoc[] classes = root.classes();
for (int i = 0; i < classes.length; i++) {
if (classes[i].getRawCommentText().length() > 0)
parsedComments.put(classes[i].name(), classes[i].getRawCommentText());
MethodDoc[] methods = classes[i].methods();
FieldDoc[] fields = classes[i].fields();
FieldDoc[] constants = classes[i].enumConstants();
for (int j = 0; j < constants.length; j++) {
FieldDoc f = constants[j];
if (f.getRawCommentText().length() > 0)
parsedComments.put(f.name(), f.getRawCommentText());
}
for (int j = 0; j < fields.length; j++) {
FieldDoc f = fields[j];
if (f.getRawCommentText().length() > 0)
parsedComments.put(f.name(), f.getRawCommentText());
}
for (int j = 0; j < methods.length; j++) {
MethodDoc m = methods[j];
if (m.getRawCommentText().length() > 0)
parsedComments.put(m.name(), m.getRawCommentText());
}
}
return true;
}
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.
*/
com.sun.tools.javadoc.Main.execute("doxygen_parsing_enums_typesafe runtime test",
"doxygen_parsing_enums_typesafe_runme", new String[]{"-quiet", "doxygen_parsing_enums_typesafe"});
wantedComments.put("E_TEST", " Test enumeration \n");
wantedComments.put("E_TEST_ONE", " the first item \n");
wantedComments.put("E_TEST_TWO", " the second \n");
int errorCount=0;
Iterator< Entry<String, String> > it = parsedComments.entrySet().iterator();
while (it.hasNext())
{
Entry<String, String> e = (Entry<String, String>) it.next();
if (!e.getValue().equals(wantedComments.get(e.getKey()))) {
System.out.println("Documentation comments for " + e.getKey() + " does not match: ");
System.out.println("\texpected:"+wantedComments.get(e.getKey()));
System.out.println("\tgot:\t"+e.getValue());
errorCount++;
}
}
if (parsedComments.size() != wantedComments.size()) {
System.out.println("Found " + (wantedComments.size()-parsedComments.size()) + " missed comment(s)!");
errorCount++;
}
System.exit(errorCount);
}
}

View file

@ -0,0 +1,93 @@
import doxygen_parsing_enums_typeunsafe.*;
import com.sun.javadoc.*;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Iterator;
public class doxygen_parsing_enums_typeunsafe_runme {
static {
try {
System.loadLibrary("doxygen_parsing_enums_typeunsafe");
} 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);
}
}
static HashMap<String, String> parsedComments = new HashMap<String, String>();
static HashMap<String, String> wantedComments = new HashMap<String, String>();
public static boolean start(RootDoc root) {
/*
This method is called by 'javadoc' and gets the whole parsed
java file, we get comments and store them
*/
ClassDoc[] classes = root.classes();
for (int i = 0; i < classes.length; i++) {
if (classes[i].getRawCommentText().length() > 0)
parsedComments.put(classes[i].name(), classes[i].getRawCommentText());
MethodDoc[] methods = classes[i].methods();
FieldDoc[] fields = classes[i].fields();
FieldDoc[] constants = classes[i].enumConstants();
for (int j = 0; j < constants.length; j++) {
FieldDoc f = constants[j];
if (f.getRawCommentText().length() > 0)
parsedComments.put(f.name(), f.getRawCommentText());
}
for (int j = 0; j < fields.length; j++) {
FieldDoc f = fields[j];
if (f.getRawCommentText().length() > 0)
parsedComments.put(f.name(), f.getRawCommentText());
}
for (int j = 0; j < methods.length; j++) {
MethodDoc m = methods[j];
if (m.getRawCommentText().length() > 0)
parsedComments.put(m.name(), m.getRawCommentText());
}
}
return true;
}
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.
*/
com.sun.tools.javadoc.Main.execute("doxygen_parsing_enums_typeunsafe runtime test",
"doxygen_parsing_enums_typeunsafe_runme", new String[]{"-quiet", "doxygen_parsing_enums_typeunsafe"});
wantedComments.put("E_TEST", " Test enumeration \n");
wantedComments.put("E_TEST_ONE", " the first item \n");
wantedComments.put("E_TEST_TWO", " the second \n");
int errorCount=0;
Iterator< Entry<String, String> > it = parsedComments.entrySet().iterator();
while (it.hasNext())
{
Entry<String, String> e = (Entry<String, String>) it.next();
if (!e.getValue().equals(wantedComments.get(e.getKey()))) {
System.out.println("Documentation comments for " + e.getKey() + " does not match: ");
System.out.println("\texpected:"+wantedComments.get(e.getKey()));
System.out.println("\tgot:\t"+e.getValue());
errorCount++;
}
}
if (parsedComments.size() != wantedComments.size()) {
System.out.println("Found " + (wantedComments.size()-parsedComments.size()) + " missed comment(s)!");
errorCount++;
}
System.exit(errorCount);
}
}

View file

@ -33,6 +33,19 @@ public class doxygen_parsing_runme {
parsedComments.put(classes[i].name(), classes[i].getRawCommentText());
MethodDoc[] methods = classes[i].methods();
FieldDoc[] fields = classes[i].fields();
FieldDoc[] constants = classes[i].enumConstants();
for (int j = 0; j < constants.length; j++) {
FieldDoc f = constants[j];
if (f.getRawCommentText().length() > 0)
parsedComments.put(f.name(), f.getRawCommentText());
}
for (int j = 0; j < fields.length; j++) {
FieldDoc f = fields[j];
if (f.getRawCommentText().length() > 0)
parsedComments.put(f.name(), f.getRawCommentText());
}
for (int j = 0; j < methods.length; j++) {
MethodDoc m = methods[j];
if (m.getRawCommentText().length() > 0)
@ -84,6 +97,11 @@ public class doxygen_parsing_runme {
}
}
if (parsedComments.size() != wantedComments.size()) {
System.out.println("Found " + (wantedComments.size()-parsedComments.size()) + " missed comment(s)!");
errorCount++;
}
System.exit(errorCount);
}
}