Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Tarassov2016-03-09 09:28:02 +0000
committerEugene Tarassov2016-03-09 09:28:02 +0000
commitd1e9fe8fd903d54b20cdbdc6492317757008a6f7 (patch)
tree6761b1a40bdc6b84dfa15c02793f4f7db6832318 /plugins
parent3a79934f54879337ae17e9d309ef29980cb61891 (diff)
downloadorg.eclipse.tcf-d1e9fe8fd903d54b20cdbdc6492317757008a6f7.tar.gz
org.eclipse.tcf-d1e9fe8fd903d54b20cdbdc6492317757008a6f7.tar.xz
org.eclipse.tcf-d1e9fe8fd903d54b20cdbdc6492317757008a6f7.zip
TCF Tests: fixed bogus test error: EchoFP test failed: 7.21866475E+21 != 7.218664750000001E+21
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/tests/TestEchoFP.java21
1 files changed, 15 insertions, 6 deletions
diff --git a/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/tests/TestEchoFP.java b/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/tests/TestEchoFP.java
index ca7692542..40847a718 100644
--- a/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/tests/TestEchoFP.java
+++ b/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/tests/TestEchoFP.java
@@ -25,6 +25,9 @@ class TestEchoFP implements ITCFTest, IDiagnostics.DoneEchoFP {
private final LinkedList<BigDecimal> msgs = new LinkedList<BigDecimal>();
private final Random rnd = new Random();
+ private static final int MAX_COUNT = 0x800;
+ private static final int MAX_TIME_MS = 4000;
+
private int count = 0;
private long start_time;
@@ -39,7 +42,7 @@ class TestEchoFP implements ITCFTest, IDiagnostics.DoneEchoFP {
}
else {
start_time = System.currentTimeMillis();
- for (int i = 0; i < 32; i++) sendMessage();
+ for (int i = 0; i < 100; i++) sendMessage();
}
}
@@ -51,7 +54,13 @@ class TestEchoFP implements ITCFTest, IDiagnostics.DoneEchoFP {
}
private boolean cmp(double x, double y) {
- return (float)x == (float)y;
+ if ((float)x == (float)y) return true;
+ if (x == 0) return false;
+ // EchoFP test failed: 7.21866475E+21 != 7.218664750000001E+21
+ // (float)x = 7.2186645E21
+ // (float)y = 7.218665E21
+ double d = Math.abs((x - y) / x);
+ return d < 1.0e-12;
}
public void doneEchoFP(IToken token, Throwable error, BigDecimal b) {
@@ -63,11 +72,11 @@ class TestEchoFP implements ITCFTest, IDiagnostics.DoneEchoFP {
else if (!cmp(s.doubleValue(), b.doubleValue())) {
test_suite.done(this, new Exception("EchoFP test failed: " + s + " != " + b));
}
- else if (count < 0x800) {
+ else if (count < MAX_COUNT) {
sendMessage();
- // Don't run the test much longer then 4 seconds
- if (count % 0x10 == 0 && System.currentTimeMillis() - start_time >= 4000) {
- count = 0x800;
+ // Don't run the test longer then MAX_TIME_MS ms
+ if (count % 0x40 == 0 && System.currentTimeMillis() - start_time >= MAX_TIME_MS) {
+ count = MAX_COUNT;
}
}
else if (msgs.isEmpty()) {

Back to the top