From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5533 invoked by alias); 28 Dec 2006 15:39:47 -0000 Received: (qmail 5524 invoked by uid 22791); 28 Dec 2006 15:39:46 -0000 X-Spam-Check-By: sourceware.org Received: from moutng.kundenserver.de (HELO moutng.kundenserver.de) (212.227.126.177) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 28 Dec 2006 15:39:39 +0000 Received: from [212.126.219.82] (helo=mail.aicas.de) by mrelayeu.kundenserver.de (node=mrelayeu3) with ESMTP (Nemesis), id 0MKxQS-1GzxLz0RPg-0003CS; Thu, 28 Dec 2006 16:39:35 +0100 Received: from mail.aicas.burg (caribic.aicas.burg [192.168.1.3]) by mail.aicas.de (Postfix) with ESMTP id C7F4354000B; Thu, 28 Dec 2006 16:39:34 +0100 (CET) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.aicas.burg (Postfix) with ESMTP id 763A86BC97F; Thu, 28 Dec 2006 16:39:34 +0100 (CET) Received: from mail.aicas.burg ([127.0.0.1]) by localhost (www.aicas.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 07167-10; Thu, 28 Dec 2006 16:39:28 +0100 (CET) Received: from [192.168.10.10] (unknown [192.168.10.10]) by mail.aicas.burg (Postfix) with ESMTP id 429146BC97E; Thu, 28 Dec 2006 16:39:28 +0100 (CET) Subject: Re: junit.framework.Assert From: Roman Kennke To: Audrius Meskauskas Cc: mauve-discuss@sourceware.org, Roman Kennke In-Reply-To: <4590364F.6020503@bluewin.ch> References: <4590364F.6020503@bluewin.ch> Content-Type: multipart/mixed; boundary="=-C7M2LfLr3o3aTh2Yc0eX" Date: Thu, 28 Dec 2006 15:39:00 -0000 Message-Id: <1167320366.4817.4.camel@localhost> Mime-Version: 1.0 X-Mailer: Evolution 2.8.1 Mailing-List: contact mauve-discuss-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: mauve-discuss-owner@sourceware.org X-SW-Source: 2006-q4/txt/msg00011.txt.bz2 --=-C7M2LfLr3o3aTh2Yc0eX Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-length: 752 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 * gnu/testlet/TestHarness.java (check(double,double,double)): New method. Tests two double values with a certain threshold. /Roman --=-C7M2LfLr3o3aTh2Yc0eX Content-Disposition: attachment; filename=patch.diff Content-Type: text/x-patch; name=patch.diff; charset=utf-8 Content-Transfer-Encoding: 7bit Content-length: 2255 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 result is equal to expected 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) { --=-C7M2LfLr3o3aTh2Yc0eX--