umagesh     2003/04/23 08:12:13

  Modified:    src/etc/testcases/filters head-tail.xml
               src/main/org/apache/tools/ant/filters StripJavaComments.java
               src/testcases/org/apache/tools/ant/filters HeadTailTest.java
  Log:
  Enable previously disabled head-tail tests.
  Make StripJavaComments recognize and retain Mac line endings.
  
  PR: 18476
  
  Submitted by: [EMAIL PROTECTED] (peter reilly)
  
  Revision  Changes    Path
  1.2       +24 -0     ant/src/etc/testcases/filters/head-tail.xml
  
  Index: head-tail.xml
  ===================================================================
  RCS file: /home/cvs/ant/src/etc/testcases/filters/head-tail.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- head-tail.xml     14 Apr 2003 15:37:45 -0000      1.1
  +++ head-tail.xml     23 Apr 2003 15:12:13 -0000      1.2
  @@ -43,6 +43,18 @@
       </copy>
     </target>
   
  +  <target name="testFilterReaderHeadLinesSkip" depends="init">
  +    <copy file="input/head-tail.test" 
  +          tofile="result/head-tail.filterReaderHeadLinesSkip.test">
  +      <filterchain>
  +        <filterreader classname="org.apache.tools.ant.filters.HeadFilter">
  +          <param name="lines" value="2"/>
  +          <param name="skip" value="2"/>
  +        </filterreader>
  +      </filterchain>
  +    </copy>
  +  </target>
  +
     <target name="testHeadAllSkip" depends="init">
       <copy file="input/head-tail.test" 
tofile="result/head-tail.headAllSkip.test">
         <filterchain>
  @@ -81,6 +93,18 @@
       <copy file="input/head-tail.test" 
tofile="result/head-tail.tailLinesSkip.test">
         <filterchain>
           <tailfilter lines="2" skip="2"/>
  +      </filterchain>
  +    </copy>
  +  </target>
  +
  +  <target name="testFilterReaderTailLinesSkip" depends="init">
  +    <copy file="input/head-tail.test" 
  +          tofile="result/head-tail.filterReaderTailLinesSkip.test">
  +      <filterchain>
  +        <filterreader classname="org.apache.tools.ant.filters.TailFilter">
  +          <param name="lines" value="2"/>
  +          <param name="skip" value="2"/>
  +        </filterreader>
         </filterchain>
       </copy>
     </target>
  
  
  
  1.11      +1 -7      
ant/src/main/org/apache/tools/ant/filters/StripJavaComments.java
  
  Index: StripJavaComments.java
  ===================================================================
  RCS file: 
/home/cvs/ant/src/main/org/apache/tools/ant/filters/StripJavaComments.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- StripJavaComments.java    22 Apr 2003 18:23:54 -0000      1.10
  +++ StripJavaComments.java    23 Apr 2003 15:12:13 -0000      1.11
  @@ -132,14 +132,8 @@
                       if (ch == '/') {
                           ch = in.read();
                           if (ch == '/') {
  -                            int prevCh = -1;
  -                            while (ch != '\n' && ch != -1) {
  -                                prevCh = ch;
  +                            while (ch != '\n' && ch != -1 && ch != '\r') {
                                   ch = in.read();
  -                            }
  -                            if ( ch == '\n' && prevCh == '\r' ) {
  -                                readAheadCh = ch;
  -                                ch = prevCh;
                               }
                           } else if (ch == '*') {
                               while (ch != -1) {
  
  
  
  1.3       +4 -8      
ant/src/testcases/org/apache/tools/ant/filters/HeadTailTest.java
  
  Index: HeadTailTest.java
  ===================================================================
  RCS file: 
/home/cvs/ant/src/testcases/org/apache/tools/ant/filters/HeadTailTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- HeadTailTest.java 22 Apr 2003 18:23:55 -0000      1.2
  +++ HeadTailTest.java 23 Apr 2003 15:12:13 -0000      1.3
  @@ -112,19 +112,17 @@
           assertTrue("testHeadLinesSkip: Result not like expected", 
fu.contentEquals(expected, result));
       }
   
  -/*
       public void testFilterReaderHeadLinesSkip() throws IOException {
           executeTarget("testFilterReaderHeadLinesSkip");
           File expected = getProject().resolveFile(
  -            "expected/head-tail.filterReaderHeadLinesSkip.test");
  +            "expected/head-tail.headLinesSkip.test");
           File result = getProject().resolveFile(
  -            "result/head-tail.headLinesSkip.test");
  +            "result/head-tail.filterReaderHeadLinesSkip.test");
           FileUtils fu = FileUtils.newFileUtils();
           assertTrue("testFilterReaderHeadLinesSkip: Result not like expected",
                      fu.contentEquals(expected, result));
       }
   
  -*/
       public void testTail() throws IOException {
           executeTarget("testTail");
           File expected = 
getProject().resolveFile("expected/head-tail.tail.test");
  @@ -157,18 +155,16 @@
           assertTrue("testTailLinesSkip: Result not like expected", 
fu.contentEquals(expected, result));
       }
   
  -/*
       public void testFilterReaderTailLinesSkip() throws IOException {
           executeTarget("testFilterReaderTailLinesSkip");
           File expected = getProject().resolveFile(
  -            "expected/head-tail.filterReaderTailLinesSkip.test");
  +            "expected/head-tail.tailLinesSkip.test");
           File result = getProject().resolveFile(
  -            "result/head-tail.tailLinesSkip.test");
  +            "result/head-tail.filterReaderTailLinesSkip.test");
           FileUtils fu = FileUtils.newFileUtils();
           assertTrue("testFilterReaderTailLinesSkip: Result not like expected",
                      fu.contentEquals(expected, result));
       }
  -*/
   
       public void testHeadTail() throws IOException {
           executeTarget("testHeadTail");
  
  
  

Reply via email to