not been commented but rather modify to trigger once they are fixed. If Unix people could tests and make sure that they pass on Unix that would be nice. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271015 13f79535-47bb-0310-9956-ffa450edef68master
@@ -54,6 +54,12 @@ | |||||
package org.apache.tools.ant.util.regexp; | package org.apache.tools.ant.util.regexp; | ||||
import java.io.IOException; | |||||
import junit.framework.AssertionFailedError; | |||||
import org.apache.tools.ant.taskdefs.condition.Os; | |||||
/** | /** | ||||
* Tests for the jakarta-regexp implementation of the Regexp interface. | * Tests for the jakarta-regexp implementation of the Regexp interface. | ||||
* | * | ||||
@@ -69,6 +75,30 @@ public class JakartaRegexpRegexpTest extends RegexpTest { | |||||
super(name); | super(name); | ||||
} | } | ||||
public void testWindowsLineSeparator() throws IOException { | |||||
if ( Os.isFamily("windows") ) { | |||||
try { | |||||
super.testWindowsLineSeparator(); | |||||
fail("Windows issue. Should trigger when this bug is fixed. {@since 1.2}"); | |||||
} catch (AssertionFailedError e){ | |||||
} | |||||
} else { | |||||
super.testWindowsLineSeparator(); | |||||
} | |||||
} | |||||
public void testUnixLineSeparator() throws IOException { | |||||
if ( Os.isFamily("windows") ){ | |||||
try { | |||||
super.testUnixLineSeparator(); | |||||
fail("Windows issue. Should trigger once this bug is fixed. {@since 1.2}"); | |||||
} catch (AssertionFailedError e){ | |||||
} | |||||
} else { | |||||
super.testUnixLineSeparator(); | |||||
} | |||||
} | |||||
/** | /** | ||||
* Fails for "default" mode. | * Fails for "default" mode. | ||||
*/ | */ | ||||
@@ -54,6 +54,10 @@ | |||||
package org.apache.tools.ant.util.regexp; | package org.apache.tools.ant.util.regexp; | ||||
import java.io.IOException; | |||||
import junit.framework.AssertionFailedError; | |||||
/** | /** | ||||
* Tests for the JDK 1.4 implementation of the RegexpMatcher interface. | * Tests for the JDK 1.4 implementation of the RegexpMatcher interface. | ||||
* | * | ||||
@@ -69,4 +73,35 @@ public class Jdk14RegexpMatcherTest extends RegexpMatcherTest { | |||||
super(name); | super(name); | ||||
} | } | ||||
public void testParagraphCharacter() throws IOException { | |||||
try { | |||||
super.testParagraphCharacter(); | |||||
fail("Should trigger once fixed. {@since JDK 1.4RC1}"); | |||||
} catch (AssertionFailedError e){ | |||||
} | |||||
} | |||||
public void testLineSeparatorCharacter() throws IOException { | |||||
try { | |||||
super.testLineSeparatorCharacter(); | |||||
fail("Should trigger once fixed. {@since JDK 1.4RC1}"); | |||||
} catch (AssertionFailedError e){ | |||||
} | |||||
} | |||||
public void testStandaloneCR() throws IOException { | |||||
try { | |||||
super.testStandaloneCR(); | |||||
fail("Should trigger once fixed. {@since JDK 1.4RC1}"); | |||||
} catch (AssertionFailedError e){ | |||||
} | |||||
} | |||||
public void testWindowsLineSeparator() throws IOException { | |||||
try { | |||||
super.testWindowsLineSeparator(); | |||||
fail("Should trigger once fixed. {@since JDK 1.4RC1}"); | |||||
} catch (AssertionFailedError e){ | |||||
} | |||||
} | |||||
} | } |
@@ -68,6 +68,8 @@ import junit.framework.TestSuite; | |||||
*/ | */ | ||||
public abstract class RegexpMatcherTest extends TestCase { | public abstract class RegexpMatcherTest extends TestCase { | ||||
public final static String UNIX_LINE = "\n"; | |||||
private RegexpMatcher reg; | private RegexpMatcher reg; | ||||
public abstract RegexpMatcher getImplementation(); | public abstract RegexpMatcher getImplementation(); | ||||
@@ -138,15 +140,50 @@ public abstract class RegexpMatcherTest extends TestCase { | |||||
reg.matches("AAaa", RegexpMatcher.MATCH_CASE_INSENSITIVE)); | reg.matches("AAaa", RegexpMatcher.MATCH_CASE_INSENSITIVE)); | ||||
} | } | ||||
// make sure there are no issues concerning line separator interpretation | |||||
// a line separator for regex (perl) is always a unix line (ie \n) | |||||
public void testParagraphCharacter() throws IOException { | |||||
reg.setPattern("end of text$"); | |||||
assertTrue("paragraph character", !reg.matches("end of text\u2029")); | |||||
} | |||||
public void testLineSeparatorCharacter() throws IOException { | |||||
reg.setPattern("end of text$"); | |||||
assertTrue("line-separator character", !reg.matches("end of text\u2028")); | |||||
} | |||||
public void testNextLineCharacter() throws IOException { | |||||
reg.setPattern("end of text$"); | |||||
assertTrue("next-line character", !reg.matches("end of text\u0085")); | |||||
} | |||||
public void testStandaloneCR() throws IOException { | |||||
reg.setPattern("end of text$"); | |||||
assertTrue("standalone CR", !reg.matches("end of text\r")); | |||||
} | |||||
public void testWindowsLineSeparator() throws IOException { | |||||
reg.setPattern("end of text$"); | |||||
assertTrue("Windows line separator", !reg.matches("end of text\r\n")); | |||||
reg.setPattern("end of text\r$"); | |||||
assertTrue("Windows line separator", reg.matches("end of text\r\n")); | |||||
} | |||||
public void testUnixLineSeparator() throws IOException { | |||||
reg.setPattern("end of text$"); | |||||
assertTrue("Unix line separator", reg.matches("end of text\n")); | |||||
} | |||||
public void testMultiVersusSingleLine() throws IOException { | public void testMultiVersusSingleLine() throws IOException { | ||||
StringWriter swr = new StringWriter(); | |||||
PrintWriter p = new PrintWriter(swr); | |||||
p.println("Line1"); | |||||
p.println("starttest Line2"); | |||||
p.println("Line3 endtest"); | |||||
p.println("Line4"); | |||||
p.close(); | |||||
String text = swr.toString(); | |||||
StringBuffer buf = new StringBuffer(); | |||||
buf.append("Line1").append(UNIX_LINE); | |||||
buf.append("starttest Line2").append(UNIX_LINE); | |||||
buf.append("Line3 endtest").append(UNIX_LINE); | |||||
buf.append("Line4").append(UNIX_LINE); | |||||
String text = buf.toString(); | |||||
doStartTest1(text); | doStartTest1(text); | ||||
doStartTest2(text); | doStartTest2(text); | ||||