harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r798657 - in /harmony/enhanced/classlib/trunk/modules/concurrent/src: main/java/java/util/concurrent/TimeUnit.java test/java/TimeUnitTest.java
Date Tue, 28 Jul 2009 19:08:34 GMT
Author: hindessm
Date: Tue Jul 28 19:08:34 2009
New Revision: 798657

URL: http://svn.apache.org/viewvc?rev=798657&view=rev
Log:
Applied patch from "[#HARMONY-6286] TimeUnit.MINUTES, HOURS, DAYS
shouldn't be present in Java 5".

Modified:
    harmony/enhanced/classlib/trunk/modules/concurrent/src/main/java/java/util/concurrent/TimeUnit.java
    harmony/enhanced/classlib/trunk/modules/concurrent/src/test/java/TimeUnitTest.java

Modified: harmony/enhanced/classlib/trunk/modules/concurrent/src/main/java/java/util/concurrent/TimeUnit.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/concurrent/src/main/java/java/util/concurrent/TimeUnit.java?rev=798657&r1=798656&r2=798657&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/concurrent/src/main/java/java/util/concurrent/TimeUnit.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/concurrent/src/main/java/java/util/concurrent/TimeUnit.java
Tue Jul 28 19:08:34 2009
@@ -83,39 +83,6 @@
         public long toDays(long d)    { return d/(C6/C3); }
         public long convert(long d, TimeUnit u) { return u.toSeconds(d); }
         int excessNanos(long d, long m) { return 0; }
-    },
-    MINUTES {
-        public long toNanos(long d)   { return x(d, C4/C0, MAX/(C4/C0)); }
-        public long toMicros(long d)  { return x(d, C4/C1, MAX/(C4/C1)); }
-        public long toMillis(long d)  { return x(d, C4/C2, MAX/(C4/C2)); }
-        public long toSeconds(long d) { return x(d, C4/C3, MAX/(C4/C3)); }
-        public long toMinutes(long d) { return d; }
-        public long toHours(long d)   { return d/(C5/C4); }
-        public long toDays(long d)    { return d/(C6/C4); }
-        public long convert(long d, TimeUnit u) { return u.toMinutes(d); }
-        int excessNanos(long d, long m) { return 0; }
-    },
-    HOURS {
-        public long toNanos(long d)   { return x(d, C5/C0, MAX/(C5/C0)); }
-        public long toMicros(long d)  { return x(d, C5/C1, MAX/(C5/C1)); }
-        public long toMillis(long d)  { return x(d, C5/C2, MAX/(C5/C2)); }
-        public long toSeconds(long d) { return x(d, C5/C3, MAX/(C5/C3)); }
-        public long toMinutes(long d) { return x(d, C5/C4, MAX/(C5/C4)); }
-        public long toHours(long d)   { return d; }
-        public long toDays(long d)    { return d/(C6/C5); }
-        public long convert(long d, TimeUnit u) { return u.toHours(d); }
-        int excessNanos(long d, long m) { return 0; }
-    },
-    DAYS {
-        public long toNanos(long d)   { return x(d, C6/C0, MAX/(C6/C0)); }
-        public long toMicros(long d)  { return x(d, C6/C1, MAX/(C6/C1)); }
-        public long toMillis(long d)  { return x(d, C6/C2, MAX/(C6/C2)); }
-        public long toSeconds(long d) { return x(d, C6/C3, MAX/(C6/C3)); }
-        public long toMinutes(long d) { return x(d, C6/C4, MAX/(C6/C4)); }
-        public long toHours(long d)   { return x(d, C6/C5, MAX/(C6/C5)); }
-        public long toDays(long d)    { return d; }
-        public long convert(long d, TimeUnit u) { return u.toDays(d); }
-        int excessNanos(long d, long m) { return 0; }
     };
 
     // Handy constants for conversion methods

Modified: harmony/enhanced/classlib/trunk/modules/concurrent/src/test/java/TimeUnitTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/concurrent/src/test/java/TimeUnitTest.java?rev=798657&r1=798656&r2=798657&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/concurrent/src/test/java/TimeUnitTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/concurrent/src/test/java/TimeUnitTest.java Tue
Jul 28 19:08:34 2009
@@ -27,17 +27,8 @@
      */
     public void testConvert() {
         for (long t = 0; t < 88888; ++t) {
-            assertEquals(t*60*60*24, 
-                         TimeUnit.SECONDS.convert(t, 
-                                                  TimeUnit.DAYS));
-            assertEquals(t*60*60, 
-                         TimeUnit.SECONDS.convert(t, 
-                                                  TimeUnit.HOURS));
-            assertEquals(t*60, 
-                         TimeUnit.SECONDS.convert(t, 
-                                                  TimeUnit.MINUTES));
-            assertEquals(t, 
-                         TimeUnit.SECONDS.convert(t, 
+            assertEquals(t,
+                         TimeUnit.SECONDS.convert(t,
                                                   TimeUnit.SECONDS));
             assertEquals(t, 
                          TimeUnit.SECONDS.convert(1000L*t, 
@@ -50,16 +41,7 @@
                                                   TimeUnit.NANOSECONDS));
 
 
-            assertEquals(1000L*t*60*60*24, 
-                         TimeUnit.MILLISECONDS.convert(t, 
-                                                  TimeUnit.DAYS));
-            assertEquals(1000L*t*60*60, 
-                         TimeUnit.MILLISECONDS.convert(t, 
-                                                  TimeUnit.HOURS));
-            assertEquals(1000L*t*60, 
-                         TimeUnit.MILLISECONDS.convert(t, 
-                                                  TimeUnit.MINUTES));
-            assertEquals(1000L*t, 
+            assertEquals(1000L*t,
                          TimeUnit.MILLISECONDS.convert(t, 
                                                   TimeUnit.SECONDS));
             assertEquals(t, 
@@ -72,16 +54,7 @@
                          TimeUnit.MILLISECONDS.convert(1000000L*t, 
                                                   TimeUnit.NANOSECONDS));
 
-            assertEquals(1000000L*t*60*60*24, 
-                         TimeUnit.MICROSECONDS.convert(t, 
-                                                  TimeUnit.DAYS));
-            assertEquals(1000000L*t*60*60, 
-                         TimeUnit.MICROSECONDS.convert(t, 
-                                                  TimeUnit.HOURS));
-            assertEquals(1000000L*t*60, 
-                         TimeUnit.MICROSECONDS.convert(t, 
-                                                  TimeUnit.MINUTES));
-            assertEquals(1000000L*t, 
+            assertEquals(1000000L*t,
                          TimeUnit.MICROSECONDS.convert(t, 
                                                   TimeUnit.SECONDS));
             assertEquals(1000L*t, 
@@ -94,16 +67,7 @@
                          TimeUnit.MICROSECONDS.convert(1000L*t, 
                                                   TimeUnit.NANOSECONDS));
 
-            assertEquals(1000000000L*t*60*60*24, 
-                         TimeUnit.NANOSECONDS.convert(t, 
-                                                  TimeUnit.DAYS));
-            assertEquals(1000000000L*t*60*60, 
-                         TimeUnit.NANOSECONDS.convert(t, 
-                                                  TimeUnit.HOURS));
-            assertEquals(1000000000L*t*60, 
-                         TimeUnit.NANOSECONDS.convert(t, 
-                                                  TimeUnit.MINUTES));
-            assertEquals(1000000000L*t, 
+            assertEquals(1000000000L*t,
                          TimeUnit.NANOSECONDS.convert(t, 
                                                   TimeUnit.SECONDS));
             assertEquals(1000000L*t, 
@@ -124,13 +88,7 @@
      */
     public void testToNanos() {
         for (long t = 0; t < 88888; ++t) {
-            assertEquals(t*1000000000L*60*60*24, 
-                         TimeUnit.DAYS.toNanos(t));
-            assertEquals(t*1000000000L*60*60, 
-                         TimeUnit.HOURS.toNanos(t));
-            assertEquals(t*1000000000L*60, 
-                         TimeUnit.MINUTES.toNanos(t));
-            assertEquals(1000000000L*t, 
+            assertEquals(1000000000L*t,
                          TimeUnit.SECONDS.toNanos(t));
             assertEquals(1000000L*t, 
                          TimeUnit.MILLISECONDS.toNanos(t));
@@ -147,13 +105,7 @@
      */
     public void testToMicros() {
         for (long t = 0; t < 88888; ++t) {
-            assertEquals(t*1000000L*60*60*24, 
-                         TimeUnit.DAYS.toMicros(t));
-            assertEquals(t*1000000L*60*60, 
-                         TimeUnit.HOURS.toMicros(t));
-            assertEquals(t*1000000L*60, 
-                         TimeUnit.MINUTES.toMicros(t));
-            assertEquals(1000000L*t, 
+            assertEquals(1000000L*t,
                          TimeUnit.SECONDS.toMicros(t));
             assertEquals(1000L*t, 
                          TimeUnit.MILLISECONDS.toMicros(t));
@@ -170,13 +122,7 @@
      */
     public void testToMillis() {
         for (long t = 0; t < 88888; ++t) {
-            assertEquals(t*1000L*60*60*24, 
-                         TimeUnit.DAYS.toMillis(t));
-            assertEquals(t*1000L*60*60, 
-                         TimeUnit.HOURS.toMillis(t));
-            assertEquals(t*1000L*60, 
-                         TimeUnit.MINUTES.toMillis(t));
-            assertEquals(1000L*t, 
+            assertEquals(1000L*t,
                          TimeUnit.SECONDS.toMillis(t));
             assertEquals(t, 
                          TimeUnit.MILLISECONDS.toMillis(t));
@@ -193,13 +139,7 @@
      */
     public void testToSeconds() {
         for (long t = 0; t < 88888; ++t) {
-            assertEquals(t*60*60*24, 
-                         TimeUnit.DAYS.toSeconds(t));
-            assertEquals(t*60*60, 
-                         TimeUnit.HOURS.toSeconds(t));
-            assertEquals(t*60, 
-                         TimeUnit.MINUTES.toSeconds(t));
-            assertEquals(t, 
+            assertEquals(t,
                          TimeUnit.SECONDS.toSeconds(t));
             assertEquals(t, 
                          TimeUnit.MILLISECONDS.toSeconds(t*1000L));
@@ -221,25 +161,6 @@
         assertEquals(Long.MIN_VALUE,
                      TimeUnit.NANOSECONDS.convert(-Long.MAX_VALUE / 4,
                                                   TimeUnit.SECONDS));
-        assertEquals(Long.MAX_VALUE,
-                     TimeUnit.NANOSECONDS.convert(Long.MAX_VALUE / 2,
-                                                  TimeUnit.MINUTES));
-        assertEquals(Long.MIN_VALUE,
-                     TimeUnit.NANOSECONDS.convert(-Long.MAX_VALUE / 4,
-                                                  TimeUnit.MINUTES));
-        assertEquals(Long.MAX_VALUE,
-                     TimeUnit.NANOSECONDS.convert(Long.MAX_VALUE / 2,
-                                                  TimeUnit.HOURS));
-        assertEquals(Long.MIN_VALUE,
-                     TimeUnit.NANOSECONDS.convert(-Long.MAX_VALUE / 4,
-                                                  TimeUnit.HOURS));
-        assertEquals(Long.MAX_VALUE,
-                     TimeUnit.NANOSECONDS.convert(Long.MAX_VALUE / 2,
-                                                  TimeUnit.DAYS));
-        assertEquals(Long.MIN_VALUE,
-                     TimeUnit.NANOSECONDS.convert(-Long.MAX_VALUE / 4,
-                                                  TimeUnit.DAYS));
-
     }
 
     /**



Mime
View raw message