git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271789 13f79535-47bb-0310-9956-ffa450edef68master
@@ -87,6 +87,42 @@ Hello World!</echo> | |||||
</loadfile> | </loadfile> | ||||
</target> | </target> | ||||
<target name="testStripJavaComments" | |||||
depends="init"> | |||||
<echo file="loadfile1.tmp"> | |||||
/* | |||||
Comment "1" | |||||
*/ | |||||
public class test1 { | |||||
//Some comment | |||||
int x = 1/2; | |||||
private static final String GREETING="*/Hello/*"; | |||||
private static final String GREETING1="/*Hello*/"; | |||||
public static void main( String args[] ) { | |||||
} | |||||
}</echo> | |||||
<echo file="nocomments.tmp"> | |||||
public class test1 { | |||||
int x = 1/2; | |||||
private static final String GREETING="*/Hello/*"; | |||||
private static final String GREETING1="/*Hello*/"; | |||||
public static void main( String args[] ) { | |||||
} | |||||
}</echo> | |||||
<loadfile srcFile="loadfile1.tmp" | |||||
property="testStripJavaComments"> | |||||
<filterchain> | |||||
<stripjavacomments/> | |||||
</filterchain> | |||||
</loadfile> | |||||
<loadfile srcFile="nocomments.tmp" | |||||
property="expected"/> | |||||
</target> | |||||
<target name="testOneLine" | <target name="testOneLine" | ||||
depends="init"> | depends="init"> | ||||
<echo | <echo | ||||
@@ -105,6 +141,7 @@ Hello World!</echo> | |||||
<target name="cleanup"> | <target name="cleanup"> | ||||
<delete file="loadfile1.tmp"/> | <delete file="loadfile1.tmp"/> | ||||
<delete file="nocomments.tmp"/> | |||||
</target> | </target> | ||||
</project> | </project> |
@@ -62,8 +62,6 @@ import java.io.Reader; | |||||
* (if you have more complex Java parsing needs, use a real lexer). | * (if you have more complex Java parsing needs, use a real lexer). | ||||
* Since this class heavily relies on the single char read function, | * Since this class heavily relies on the single char read function, | ||||
* you are reccomended to make it work on top of a buffered reader. | * you are reccomended to make it work on top of a buffered reader. | ||||
* | |||||
* @author <a href="mailto:umagesh@apache.org">Magesh Umasankar</a> | |||||
*/ | */ | ||||
public final class StripJavaComments | public final class StripJavaComments | ||||
extends BaseFilterReader | extends BaseFilterReader | ||||
@@ -173,6 +173,17 @@ public class LoadFileTest extends BuildFileTest { | |||||
} | } | ||||
} | } | ||||
/** | |||||
* A unit test for JUnit | |||||
*/ | |||||
public void testStripJavaComments() | |||||
throws BuildException { | |||||
executeTarget("testStripJavaComments"); | |||||
String expected = project.getProperty("expected"); | |||||
if(!project.getProperty("testStripJavaComments").equals(expected)) { | |||||
fail("StripJavaComments broken"); | |||||
} | |||||
} | |||||
/** | /** | ||||
* A unit test for JUnit | * A unit test for JUnit | ||||