Fix remaining tests for java.util.regex

This commit is contained in:
Alexey Andreev 2015-06-21 08:41:36 +03:00
parent ec463124c9
commit 4641f9ca87
7 changed files with 11 additions and 17 deletions

View File

@ -183,7 +183,7 @@ class TMatchResultImpl implements TMatchResult {
throw new IllegalStateException();
}
if (group < 0 || group > groupCount) {
if (group < 0 || group >= groupCount) {
throw new IndexOutOfBoundsException(String.valueOf(group));
}
}

View File

@ -131,6 +131,9 @@ public final class TMatcher implements TMatchResult {
}
if (nextBackSlashed) {
if (index >= repl.length) {
throw new IndexOutOfBoundsException();
}
res.append(repl[index]);
nextBackSlashed = false;
} else {
@ -158,8 +161,6 @@ public final class TMatcher implements TMatchResult {
replacementPos += group.length();
res.append(group);
} catch (IndexOutOfBoundsException iob) {
throw iob;
} catch (Exception e) {
throw new IllegalArgumentException("");
}
@ -316,10 +317,6 @@ public final class TMatcher implements TMatchResult {
*/
@Override
public String group(int group) {
if (group < 0 || group > matchResult.groupCount()) {
throw new IndexOutOfBoundsException("Index " + group + " if out of range [0; " +
matchResult.groupCount() + ")");
}
return matchResult.group(group);
}

View File

@ -16,17 +16,17 @@
package org.teavm.classlib.java.util.regex;
import static org.junit.Assert.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import org.junit.Test;
import junit.framework.TestCase;
/**
* Tests Pattern compilation modes and modes triggered in pattern strings
*/
@SuppressWarnings("nls")
public class ModeTest extends TestCase {
public class ModeTest {
@Test
public void testCase() throws PatternSyntaxException {
Pattern p;

View File

@ -16,15 +16,15 @@
package org.teavm.classlib.java.util.regex;
import static org.junit.Assert.*;
import java.util.regex.Pattern;
import org.junit.Test;
import junit.framework.TestCase;
/**
* Test boundary and error conditions in java.util.regex.Pattern
*/
@SuppressWarnings("nls")
public class PatternErrorTest extends TestCase {
public class PatternErrorTest {
@Test
public void testCompileErrors() throws Exception {
// null regex string - should get NullPointerException

View File

@ -16,17 +16,17 @@
package org.teavm.classlib.java.util.regex;
import static org.junit.Assert.*;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import org.junit.Test;
import junit.framework.TestCase;
/**
* TODO Type description
*/
@SuppressWarnings("nls")
public class PatternSyntaxExceptionTest extends TestCase {
public class PatternSyntaxExceptionTest {
@Test
public void testCase() {
String regex = "(";

View File

@ -23,7 +23,7 @@ import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import org.junit.Test;
public class PatternTest {
public class PatternTest {
String[] testPatterns = {
"(a|b)*abb",
"(1*2*3*4*)*567",

View File

@ -23,9 +23,6 @@ import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import org.junit.Test;
/**
* TODO Type description
*/
public class SplitTest {
@Test