* junit.framework.Assert
@ 2006-12-25 20:36 Audrius Meskauskas
2006-12-27 15:32 ` junit.framework.Assert Mark Wielaard
2006-12-28 15:39 ` junit.framework.Assert Roman Kennke
0 siblings, 2 replies; 3+ messages in thread
From: Audrius Meskauskas @ 2006-12-25 20:36 UTC (permalink / raw)
To: mauve-discuss, Roman Kennke
Today I have discovered that junit.framework.Assert seems not
compileable, because it twice calls the non existing methods of the
TestHarness:
check(double, double, double).
It seems trivial to implement the workaround. Should we fix this?
Audrius.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: junit.framework.Assert
2006-12-25 20:36 junit.framework.Assert Audrius Meskauskas
@ 2006-12-27 15:32 ` Mark Wielaard
2006-12-28 15:39 ` junit.framework.Assert Roman Kennke
1 sibling, 0 replies; 3+ messages in thread
From: Mark Wielaard @ 2006-12-27 15:32 UTC (permalink / raw)
To: Audrius Meskauskas; +Cc: mauve-discuss, Roman Kennke
Hi Audrius,
On Mon, 2006-12-25 at 21:36 +0100, Audrius Meskauskas wrote:
> Today I have discovered that junit.framework.Assert seems not
> compileable, because it twice calls the non existing methods of the
> TestHarness:
> check(double, double, double).
>
> It seems trivial to implement the workaround. Should we fix this?
Yes, please. I just noticed this today. I assume this class isn't
compiled in the default Makefile/Harness implementation. But it is bad
to have non-compilable classes in the tree (makes some IDEs like Eclipse
really unhappy).
Cheers,
Mark
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: junit.framework.Assert
2006-12-25 20:36 junit.framework.Assert Audrius Meskauskas
2006-12-27 15:32 ` junit.framework.Assert Mark Wielaard
@ 2006-12-28 15:39 ` Roman Kennke
1 sibling, 0 replies; 3+ messages in thread
From: Roman Kennke @ 2006-12-28 15:39 UTC (permalink / raw)
To: Audrius Meskauskas; +Cc: mauve-discuss, Roman Kennke
[-- Attachment #1: Type: text/plain, Size: 752 bytes --]
Hi there,
Am Montag, den 25.12.2006, 21:36 +0100 schrieb Audrius Meskauskas:
> Today I have discovered that junit.framework.Assert seems not
> compileable, because it twice calls the non existing methods of the
> TestHarness:
> check(double, double, double).
>
> It seems trivial to implement the workaround. Should we fix this?
Ugh. Seems like I forgot to check this bit in when I implemented the
JUnit API in Mauve. A wonder that nobody stepped over this so far,
especially since I already checked in a bulk of tests based on the JUnit
API. Here comes the fix...
2006-12-28 Roman Kennke <kennke@aicas.com>
* gnu/testlet/TestHarness.java
(check(double,double,double)): New method. Tests two double values
with a certain threshold.
/Roman
[-- Attachment #2: patch.diff --]
[-- Type: text/x-patch, Size: 2255 bytes --]
Index: gnu/testlet/TestHarness.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/TestHarness.java,v
retrieving revision 1.26
diff -u -1 -5 -r1.26 TestHarness.java
--- gnu/testlet/TestHarness.java 31 May 2006 17:21:42 -0000 1.26
+++ gnu/testlet/TestHarness.java 28 Dec 2006 15:36:55 -0000
@@ -115,30 +115,56 @@
// and all without relying on java.lang.Double (which may
// itself be buggy - else why would we be testing it? ;)
// For 0, we switch to infinities, and for NaN, we rely
// on the identity in JLS 15.21.1 that NaN != NaN is true.
boolean ok = (result == expected ? (result != 0)
|| (1 / result == 1 / expected)
: (result != result)
&& (expected != expected));
check(ok);
if (! ok)
// If Double.toString() is buggy, this debug statement may
// accidentally show the same string for two different doubles!
debug("got " + result + " but expected " + expected);
}
+ /**
+ * Checks if <code>result</code> is equal to <code>expected</code> and
+ * take a rounding delta into account.
+ *
+ * @param result the actual result
+ * @param expected the expected value
+ * @param delta the rounding delta
+ */
+ public void check(double result, double expected, double delta)
+ {
+ boolean ok = true;
+ if (Double.isInfinite(expected))
+ {
+ if (result != expected)
+ ok = false;
+ }
+ else if (! (Math.abs(expected - result) <= delta))
+ ok = false;
+
+ check(ok);
+ if (! ok)
+ // If Double.toString() is buggy, this debug statement may
+ // accidentally show the same string for two different doubles!
+ debug("got " + result + " but expected " + expected);
+ }
+
// These methods are like the above, but checkpoint first.
public void check(boolean result, String name)
{
checkPoint(name);
check(result);
}
public void check(Object result, Object expected, String name)
{
checkPoint(name);
check(result, expected);
}
public void check(boolean result, boolean expected, String name)
{
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-12-28 15:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-25 20:36 junit.framework.Assert Audrius Meskauskas
2006-12-27 15:32 ` junit.framework.Assert Mark Wielaard
2006-12-28 15:39 ` junit.framework.Assert Roman Kennke
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).