[jruby-joni] 130/194: better test log
Hideki Yamane
henrich at moszumanska.debian.org
Thu Feb 1 12:04:34 UTC 2018
This is an automated email from the git hooks/post-receive script.
henrich pushed a commit to branch debian/sid
in repository jruby-joni.
commit f6df5f08d94ff293f680f1b54ffd96464bbb803f
Author: Marcin Mielzynski <lopx at gazeta.pl>
Date: Tue Jan 9 21:10:37 2018 +0100
better test log
---
src/org/joni/Syntax.java | 17 ++++++++++--
test/org/joni/test/Test.java | 61 ++++++++++++++++++++++++++------------------
2 files changed, 51 insertions(+), 27 deletions(-)
diff --git a/src/org/joni/Syntax.java b/src/org/joni/Syntax.java
index 0b06267..028edc9 100644
--- a/src/org/joni/Syntax.java
+++ b/src/org/joni/Syntax.java
@@ -24,6 +24,7 @@ import static org.joni.constants.MetaChar.INEFFECTIVE_META_CHAR;
import org.joni.constants.SyntaxProperties;
public final class Syntax implements SyntaxProperties {
+ public final String name;
private final int op;
private final int op2;
private final int op3;
@@ -31,7 +32,8 @@ public final class Syntax implements SyntaxProperties {
public final int options;
public final MetaCharTable metaCharTable;
- public Syntax(int op, int op2, int op3, int behavior, int options, MetaCharTable metaCharTable) {
+ public Syntax(String name, int op, int op2, int op3, int behavior, int options, MetaCharTable metaCharTable) {
+ this.name = name;
this.op = op;
this.op2 = op2;
this.op3 = op3;
@@ -418,6 +420,7 @@ public final class Syntax implements SyntaxProperties {
}
public static final Syntax RUBY = new Syntax(
+ "RUBY",
(( GNU_REGEX_OP | OP_QMARK_NON_GREEDY |
OP_ESC_OCTAL3 | OP_ESC_X_HEX2 |
OP_ESC_X_BRACE_HEX8 | OP_ESC_CONTROL_CHARS |
@@ -467,9 +470,10 @@ public final class Syntax implements SyntaxProperties {
public static final Syntax DEFAULT = RUBY;
- public static final Syntax TEST = new Syntax(RUBY.op, RUBY.op2, RUBY.op3, RUBY.behavior, RUBY.options & ~ Option.ASCII_RANGE, RUBY.metaCharTable);
+ public static final Syntax TEST = new Syntax("TEST", RUBY.op, RUBY.op2, RUBY.op3, RUBY.behavior, RUBY.options & ~ Option.ASCII_RANGE, RUBY.metaCharTable);
public static final Syntax ASIS = new Syntax(
+ "ASIS",
0,
OP2_INEFFECTIVE_ESCAPE,
@@ -491,6 +495,7 @@ public final class Syntax implements SyntaxProperties {
);
public static final Syntax PosixBasic = new Syntax(
+ "PosixBasic",
(POSIX_COMMON_OP | OP_ESC_LPAREN_SUBEXP |
OP_ESC_BRACE_INTERVAL ),
@@ -513,6 +518,7 @@ public final class Syntax implements SyntaxProperties {
);
public static final Syntax PosixExtended = new Syntax(
+ "PosixExtended",
( POSIX_COMMON_OP | OP_LPAREN_SUBEXP |
OP_BRACE_INTERVAL |
OP_PLUS_ONE_INF | OP_QMARK_ZERO_ONE |OP_VBAR_ALT ),
@@ -539,6 +545,7 @@ public final class Syntax implements SyntaxProperties {
);
public static final Syntax Emacs = new Syntax(
+ "Emacs",
( OP_DOT_ANYCHAR | OP_BRACKET_CC |
OP_ESC_BRACE_INTERVAL |
OP_ESC_LPAREN_SUBEXP | OP_ESC_VBAR_ALT |
@@ -565,6 +572,7 @@ public final class Syntax implements SyntaxProperties {
);
public static final Syntax Grep = new Syntax(
+ "Grep",
( OP_DOT_ANYCHAR | OP_BRACKET_CC | OP_POSIX_BRACKET |
OP_ESC_BRACE_INTERVAL | OP_ESC_LPAREN_SUBEXP |
OP_ESC_VBAR_ALT |
@@ -592,6 +600,7 @@ public final class Syntax implements SyntaxProperties {
);
public static final Syntax GnuRegex = new Syntax(
+ "GnuRegex",
GNU_REGEX_OP,
0,
@@ -613,6 +622,7 @@ public final class Syntax implements SyntaxProperties {
);
public static final Syntax Java = new Syntax(
+ "Java",
(( GNU_REGEX_OP | OP_QMARK_NON_GREEDY |
OP_ESC_CONTROL_CHARS | OP_ESC_C_CONTROL |
OP_ESC_OCTAL3 | OP_ESC_X_HEX2 )
@@ -642,6 +652,7 @@ public final class Syntax implements SyntaxProperties {
);
public static final Syntax Perl = new Syntax(
+ "Perl",
(( GNU_REGEX_OP | OP_QMARK_NON_GREEDY |
OP_ESC_OCTAL3 | OP_ESC_X_HEX2 |
OP_ESC_X_BRACE_HEX8 | OP_ESC_CONTROL_CHARS |
@@ -670,6 +681,7 @@ public final class Syntax implements SyntaxProperties {
);
public static final Syntax PerlNG = new Syntax(
+ "PerlNG",
(( GNU_REGEX_OP | OP_QMARK_NON_GREEDY |
OP_ESC_OCTAL3 | OP_ESC_X_HEX2 |
OP_ESC_X_BRACE_HEX8 | OP_ESC_CONTROL_CHARS |
@@ -703,6 +715,7 @@ public final class Syntax implements SyntaxProperties {
);
public static final Syntax ECMAScript = new Syntax(
+ "ECMAScript",
(( GNU_REGEX_OP | OP_QMARK_NON_GREEDY |
OP_ESC_OCTAL3 | OP_ESC_X_HEX2 |
OP_ESC_CONTROL_CHARS | OP_ESC_C_CONTROL |
diff --git a/test/org/joni/test/Test.java b/test/org/joni/test/Test.java
index 1c445cd..5feeddc 100644
--- a/test/org/joni/test/Test.java
+++ b/test/org/joni/test/Test.java
@@ -49,14 +49,24 @@ public abstract class Test {
public abstract String testEncoding();
public abstract Syntax syntax();
- protected String repr(byte[]bytes) {
+ protected String repr(byte[] bytes) {
return new String(bytes);
}
- protected int length(byte[]bytes) {
+ protected int length(byte[] bytes) {
return bytes.length;
}
+ protected String reprTest(byte[] pattern, byte[]str, int option) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("Pattern: [/").append(repr(pattern)).append("/]");
+ sb.append(" Str: [\"").append(repr(str)).append("\"]");
+ sb.append(" Encoding: [" + encoding() + "]");
+ sb.append(" Option: [" + Option.toString(option) + "]");
+ sb.append(" Syntax: [" + syntax().name + "]");
+ return sb.toString();
+ }
+
protected void assertTrue(boolean expression, String failMessage) {
if (expression) {
nsucc++;
@@ -66,23 +76,23 @@ public abstract class Test {
}
}
- public void xx(byte[]pattern, byte[]str, int from, int to, int mem, boolean not) throws InterruptedException {
+ public void xx(byte[] pattern, byte[] str, int from, int to, int mem, boolean not) throws InterruptedException {
xx(pattern, str, from, to, mem, not, option());
}
- public int xx(byte[]pattern, byte[]str, int from, int to, int mem, boolean not, int option) throws InterruptedException {
+ public int xx(byte[] pattern, byte[] str, int from, int to, int mem, boolean not, int option) throws InterruptedException {
Regex reg;
try {
reg = new Regex(pattern, 0, length(pattern), option, encoding(), syntax(), TEST_WARNINGS);
} catch (JOniException je) {
- Config.err.println("Pattern: " + repr(pattern) + " Str: " + repr(str));
+ Config.err.println(reprTest(pattern, str, option));
je.printStackTrace(Config.err);
Config.err.println("ERROR: " + je.getMessage());
nerror++;
return Matcher.FAILED;
} catch (Exception e) {
- Config.err.println("Pattern: " + repr(pattern) + " Str: " + repr(str));
+ Config.err.println(reprTest(pattern, str, option));
e.printStackTrace(Config.err);
Config.err.println("SEVERE ERROR: " + e.getMessage());
nerror++;
@@ -97,7 +107,7 @@ public abstract class Test {
r = m.searchInterruptible(0, length(str), Option.NONE);
region = m.getEagerRegion();
} catch (JOniException je) {
- Config.err.println("Pattern: " + repr(pattern) + " Str: " + repr(str));
+ Config.err.println("Pattern: " + reprTest(pattern, str, option));
je.printStackTrace(Config.err);
Config.err.println("ERROR: " + je.getMessage());
nerror++;
@@ -105,7 +115,7 @@ public abstract class Test {
} catch (InterruptedException e) {
throw e;
} catch (Exception e) {
- Config.err.println("Pattern: " + repr(pattern) + " Str: " + repr(str));
+ Config.err.println("Pattern: " + reprTest(pattern, str, option));
e.printStackTrace(Config.err);
Config.err.println("SEVERE ERROR: " + e.getMessage());
nerror++;
@@ -114,24 +124,23 @@ public abstract class Test {
if (r == -1) {
if (not) {
- if (VERBOSE) Config.log.println("OK(N): /" + repr(pattern) + "/ '" + repr(str) + "'");
+ if (VERBOSE) Config.log.println("OK(NOT): " + reprTest(pattern, str, option));
nsucc++;
} else {
- Config.log.println("FAIL: /" + repr(pattern) + "/ '" + repr(str) + "'");
+ Config.log.println("FAIL: " + reprTest(pattern, str, option));
nfail++;
}
} else {
if (not) {
- Config.log.println("FAIL(N): /" + repr(pattern) + "/ '" + repr(str) + "'");
+ Config.log.println("FAIL(NOT): " + reprTest(pattern, str, option));
nfail++;
} else {
if (region.beg[mem] == from && region.end[mem] == to) {
- if (VERBOSE) Config.log.println("OK: /" + repr(pattern) + "/ '" +repr(str) + "'");
+ if (VERBOSE) Config.log.println("OK: " + reprTest(pattern, str, option));
nsucc++;
} else {
- Config.log.println("FAIL: /" + repr(pattern) + "/ '" + repr(str) + "' " +
- from + "-" + to + " : " + region.beg[mem] + "-" + region.end[mem]
- );
+ Config.log.println("FAIL: " + reprTest(pattern, str, option) + " Groups: [Exp " + from + "-" + to + ", Act "
+ + region.beg[mem] + "-" + region.end[mem] + "]");
nfail++;
}
}
@@ -139,23 +148,23 @@ public abstract class Test {
return r;
}
- protected void x2(byte[]pattern, byte[]str, int from, int to) throws InterruptedException {
+ protected void x2(byte[] pattern, byte[] str, int from, int to) throws InterruptedException {
xx(pattern, str, from, to, 0, false);
}
- protected void x2(byte[]pattern, byte[]str, int from, int to, int option) throws InterruptedException {
+ protected void x2(byte[] pattern, byte[] str, int from, int to, int option) throws InterruptedException {
xx(pattern, str, from, to, 0, false, option);
}
- protected void x3(byte[]pattern, byte[]str, int from, int to, int mem) throws InterruptedException {
+ protected void x3(byte[] pattern, byte[] str, int from, int to, int mem) throws InterruptedException {
xx(pattern, str, from, to, mem, false);
}
- protected void n(byte[]pattern, byte[]str) throws InterruptedException {
+ protected void n(byte[] pattern, byte[] str) throws InterruptedException {
xx(pattern, str, 0, 0, 0, true);
}
- protected void n(byte[]pattern, byte[]str, int option) throws InterruptedException {
+ protected void n(byte[] pattern, byte[] str, int option) throws InterruptedException {
xx(pattern, str, 0, 0, 0, true, option);
}
@@ -163,8 +172,9 @@ public abstract class Test {
xxs(pattern, str, from, to, mem, not, option());
}
- public void xxs(String pattern, String str, int from, int to, int mem, boolean not, int option) throws InterruptedException {
- try{
+ public void xxs(String pattern, String str, int from, int to, int mem, boolean not, int option)
+ throws InterruptedException {
+ try {
xx(pattern.getBytes(testEncoding()), str.getBytes(testEncoding()), from, to, mem, not, option);
} catch (UnsupportedEncodingException uee) {
uee.printStackTrace();
@@ -176,19 +186,20 @@ public abstract class Test {
}
public int x2s(String pattern, String str, int from, int to, int option) throws InterruptedException {
- try{
+ try {
return xx(pattern.getBytes(testEncoding()), str.getBytes(testEncoding()), from, to, 0, false, option);
} catch (UnsupportedEncodingException uee) {
uee.printStackTrace();
return Matcher.FAILED;
}
}
+
public void x3s(String pattern, String str, int from, int to, int mem) throws InterruptedException {
x3s(pattern, str, from, to, mem, option());
}
public void x3s(String pattern, String str, int from, int to, int mem, int option) throws InterruptedException {
- try{
+ try {
xx(pattern.getBytes(testEncoding()), str.getBytes(testEncoding()), from, to, mem, false, option);
} catch (UnsupportedEncodingException uee) {
uee.printStackTrace();
@@ -200,7 +211,7 @@ public abstract class Test {
}
public void ns(String pattern, String str, int option) throws InterruptedException {
- try{
+ try {
xx(pattern.getBytes(testEncoding()), str.getBytes(testEncoding()), 0, 0, 0, true, option);
} catch (UnsupportedEncodingException uee) {
uee.printStackTrace();
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jruby-joni.git
More information about the pkg-java-commits
mailing list