From: Roman Kennke <roman.kennke@aicas.com>
To: Audrius Meskauskas <audriusa@bluewin.ch>
Cc: mauve-discuss@sourceware.org, Roman Kennke <kennke@aicas.com>
Subject: Re: junit.framework.Assert
Date: Thu, 28 Dec 2006 15:39:00 -0000 [thread overview]
Message-ID: <1167320366.4817.4.camel@localhost> (raw)
In-Reply-To: <4590364F.6020503@bluewin.ch>
[-- 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)
{
prev parent reply other threads:[~2006-12-28 15:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1167320366.4817.4.camel@localhost \
--to=roman.kennke@aicas.com \
--cc=audriusa@bluewin.ch \
--cc=kennke@aicas.com \
--cc=mauve-discuss@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).