This is the mail archive of the
mauve-patches@sourceware.org
mailing list for the Mauve project.
FYI: PR27362 regression test about Calendar.clear(int) swallowing pending changes
- From: Olivier Jolly <olivier dot jolly at pcedev dot com>
- To: Mauve Patch List <mauve-patches at sources dot redhat dot com>
- Date: Sat, 06 May 2006 17:43:30 +0200
- Subject: FYI: PR27362 regression test about Calendar.clear(int) swallowing pending changes
Hi,
here is a regression test about Calendar.clear(int) which currently
swallow pending changes on a dirty calendar. It is related to PR 27362
+Olivier
2006-05-06 Olivier Jolly <olivier.jolly@pcedev.com>
* gnu/testlet/java/util/Calendar/add.java: (test): Added call to the new
test.
(testPreviousDate): Regression test for PR27362, which ensures that
Calendar.clear(int) doesn't swallow previous calendar changes.
Index: add.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/util/Calendar/add.java,v
retrieving revision 1.4
diff -u -r1.4 add.java
--- add.java 1 May 2006 14:36:18 -0000 1.4
+++ add.java 6 May 2006 15:39:07 -0000
@@ -1,6 +1,6 @@
// Test Calendar.add().
-// Copyright (c) 2001 Red Hat
+// Copyright (c) 2001, 2006 Red Hat
// Written by Tom Tromey <tromey@redhat.com>
// This file is part of Mauve.
@@ -89,5 +89,37 @@
harness.check (cdf.format (k.getTime ()),
"Sat, 1 Mar 1980 10:00:00 GMT",
"wrap up");
+
+ testPreviousDate(harness);
+
}
+
+ public void testPreviousDate(TestHarness harness)
+ {
+ Calendar calendar = Calendar.getInstance();
+ Date now = new Date();
+
+ // Calculate the start of today.
+ calendar.setTime(now);
+ calendar.clear(Calendar.HOUR_OF_DAY);
+ calendar.clear(Calendar.MINUTE);
+ calendar.clear(Calendar.SECOND);
+ calendar.clear(Calendar.MILLISECOND);
+
+ Date todayStart = calendar.getTime();
+
+ // Calculate the start of yesterday.
+ calendar.setTime(now);
+ calendar.add(Calendar.DATE, -1); // this change shouldn't be lost
+ calendar.clear(Calendar.HOUR_OF_DAY);
+ calendar.clear(Calendar.MINUTE);
+ calendar.clear(Calendar.SECOND);
+ calendar.clear(Calendar.MILLISECOND);
+
+ Date yesterdayStart = calendar.getTime();
+
+ harness.check(yesterdayStart.before(todayStart),
+ "PR27362: Check that clear didn't swallow a previous add() call");
+ }
+
}