Implements missing 1.5 features from the Java number classes.  IntegerTest is currently broken.

Patch by: fabbott
Review by: me (with reservations)


git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@1609 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/super/com/google/gwt/emul/java/lang/Boolean.java b/user/super/com/google/gwt/emul/java/lang/Boolean.java
index 4b4f43b..6c2b46a 100644
--- a/user/super/com/google/gwt/emul/java/lang/Boolean.java
+++ b/user/super/com/google/gwt/emul/java/lang/Boolean.java
@@ -28,6 +28,13 @@
 
   // CHECKSTYLE_ON
 
+  public static Boolean parseString(String s) {
+    if (s != null && s.equalsIgnoreCase("true")) {
+      return TRUE;
+    }
+    return FALSE;
+  }
+
   public static String toString(boolean x) {
     return String.valueOf(x);
   }
diff --git a/user/super/com/google/gwt/emul/java/lang/Byte.java b/user/super/com/google/gwt/emul/java/lang/Byte.java
index d968e77..eacee7e 100644
--- a/user/super/com/google/gwt/emul/java/lang/Byte.java
+++ b/user/super/com/google/gwt/emul/java/lang/Byte.java
@@ -22,6 +22,7 @@
 
   public static final byte MIN_VALUE = (byte) 0x80;
   public static final byte MAX_VALUE = (byte) 0x7F;
+  public static final int SIZE = 8;
 
   // Box all values according to JLS
   private static Byte[] boxedValues = new Byte[256];
@@ -32,7 +33,7 @@
 
   /**
    * @skip
-   *
+   * 
    * Here for shared implementation with Arrays.hashCode
    */
   public static int hashCode(byte b) {
diff --git a/user/super/com/google/gwt/emul/java/lang/Double.java b/user/super/com/google/gwt/emul/java/lang/Double.java
index bd13405..ce65260 100644
--- a/user/super/com/google/gwt/emul/java/lang/Double.java
+++ b/user/super/com/google/gwt/emul/java/lang/Double.java
@@ -21,9 +21,16 @@
 public final class Double extends Number implements Comparable<Double> {
   public static final double MAX_VALUE = 1.7976931348623157e+308;
   public static final double MIN_VALUE = 4.9e-324;
+  public static final double MIN_NORMAL = 2.2250738585072014e-308;
+  public static final int MAX_EXPONENT = 1023; 
+                             // ==Math.getExponent(Double.MAX_VALUE);
+  public static final int MIN_EXPONENT = -1022; 
+                             // ==Math.getExponent(Double.MIN_NORMAL);;
+
   public static final double NaN = 0d / 0d;
   public static final double NEGATIVE_INFINITY = -1d / 0d;
   public static final double POSITIVE_INFINITY = 1d / 0d;
+  public static final int SIZE = 64;
 
   public static int compare(double x, double y) {
     if (x < y) {
diff --git a/user/super/com/google/gwt/emul/java/lang/Float.java b/user/super/com/google/gwt/emul/java/lang/Float.java
index 8dd73fe..96e3fc0 100644
--- a/user/super/com/google/gwt/emul/java/lang/Float.java
+++ b/user/super/com/google/gwt/emul/java/lang/Float.java
@@ -21,9 +21,13 @@
 public final class Float extends Number implements Comparable<Float> {
   public static final float MAX_VALUE = 3.4028235e+38f;
   public static final float MIN_VALUE = 1.4e-45f;
+  public static final float MAX_EXPONENT = 127;
+  public static final float MIN_EXPONENT = -126;
+  public static final float MIN_NORMAL = 1.1754943508222875E-38f;
   public static final float NaN = 0f / 0f;
   public static final float NEGATIVE_INFINITY = -1f / 0f;
   public static final float POSITIVE_INFINITY = 1f / 0f;
+  public static final int SIZE = 32;
 
   public static int compare(float x, float y) {
     if (x < y) {
diff --git a/user/super/com/google/gwt/emul/java/lang/Integer.java b/user/super/com/google/gwt/emul/java/lang/Integer.java
index d21d1f0..4427deb 100644
--- a/user/super/com/google/gwt/emul/java/lang/Integer.java
+++ b/user/super/com/google/gwt/emul/java/lang/Integer.java
@@ -22,6 +22,7 @@
 
   public static final int MIN_VALUE = 0x80000000;
   public static final int MAX_VALUE = 0x7fffffff;
+  public static final int SIZE = 32;
 
   // Box values according to JLS - between -128 and 127
   private static Integer[] boxedValues = new Integer[256];
@@ -43,13 +44,61 @@
 
   /**
    * @skip
-   *
+   * 
    * Here for shared implementation with Arrays.hashCode
    */
   public static int hashCode(int i) {
     return i;
   }
 
+  public static int highestOneBit(int i) {
+    if (i < 0) {
+      return MIN_VALUE;
+    } else {
+      int rtn;
+      for (rtn = 0x40000000; (rtn >> 1) > i; rtn = rtn >> 1) {
+        // loop down until smaller
+      }
+      return rtn;
+    }
+  }
+
+  public static int lowestOneBit(int i) {
+    if (i == 0) {
+      return 32;
+    } else {
+      int r = 1;
+      while ((r & i) != 0) {
+        r = r * 2;
+      }
+      return r;
+    }
+  }
+
+  public static int numberOfLeadingZeros(int i) {
+    if (i < 0) {
+      return 0;
+    } else if (i == 0) {
+      return SIZE;
+    } else {
+      return SIZE - 1 - (int) Math.floor(Math.log(i) / Math.log(2.0d));
+    }
+  }
+
+  public static int numberOfTrailingZeros(int i) {
+    if (i < 0) {
+      return 0;
+    } else if (i == 0) {
+      return SIZE;
+    } else {
+      int rtn = 0;
+      for (int r = 1; (r & i) != 0; r = r * 2) {
+        rtn++;
+      }
+      return rtn;
+    }
+  }
+
   public static int parseInt(String s) throws NumberFormatException {
     return parseInt(s, 10);
   }
@@ -58,6 +107,49 @@
     return (int) __parseAndValidateLong(s, radix, MIN_VALUE, MAX_VALUE);
   }
 
+  public static int reverse(int i) {
+    int acc = 0;
+    int front = 0x80000000;
+    int back = 1;
+    int swing = 31;
+    while (swing > 15) {
+      acc = acc | ((i & front) >> swing) | ((i & back) << swing);
+      swing--;
+      front = front >> 1;
+      back = back << 1;
+    }
+    return acc;
+  }
+
+  public static int reverseBytes(int i) {
+    return ((i & 0xff) << 24) | ((i & 0xff00) << 8) | ((i & 0xff0000) >> 8)
+        | ((i & 0xff000000) >> 24);
+  }
+
+  public static int rotateLeft(int i, int distance) {
+    while (distance-- > 0) {
+      i = i << 1 | ((i < 0) ? 1 : 0);
+    }
+    return i;
+  }
+
+  public static int rotateRight(int i, int distance) {
+    while (distance-- > 0) {
+      i = ((i & 1) == 0 ? 0 : 0x80000000) | i >> 1;
+    }
+    return i;
+  }
+
+  public static int signum(int i) {
+    if (i == 0) {
+      return 0;
+    } else if (i < 0) {
+      return -1;
+    } else {
+      return 1;
+    }
+  }
+
   public static String toBinaryString(int x) {
     return Long.toBinaryString(x);
   }
diff --git a/user/super/com/google/gwt/emul/java/lang/Long.java b/user/super/com/google/gwt/emul/java/lang/Long.java
index ba8e9e7..95c0c54 100644
--- a/user/super/com/google/gwt/emul/java/lang/Long.java
+++ b/user/super/com/google/gwt/emul/java/lang/Long.java
@@ -1,12 +1,12 @@
 /*
  * Copyright 2007 Google Inc.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  * use this file except in compliance with the License. You may obtain a copy of
  * the License at
- * 
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -21,9 +21,20 @@
 public final class Long extends Number implements Comparable<Long> {
   public static final long MIN_VALUE = 0x8000000000000000L;
   public static final long MAX_VALUE = 0x7fffffffffffffffL;
+  public static final int SIZE = 64;
 
   // Box values according to JLS - between -128 and 127
   private static Long[] boxedValues = new Long[256];
+  
+  public static int bitCount (long i) {
+    int cnt = 0;
+    for (long q = MIN_VALUE; q > 0; q = q >> 1) {
+      if ((q & i) != 0) {
+        cnt++;
+      }
+    }
+    return cnt;
+  }
 
   public static Long decode(String s) throws NumberFormatException {
     return new Long(__decodeAndValidateLong(s, MIN_VALUE, MAX_VALUE));
@@ -36,6 +47,54 @@
     return (int) l;
   }
 
+  public static long highestOneBit (long i) {
+    if (i < 0) {
+      return MIN_VALUE;
+   } else {
+      long rtn;
+      for (rtn = 0x4000000000000000L; (rtn >> 1) > i; rtn = rtn >> 1) {
+        // loop down until smaller
+      }
+      return rtn;
+    }
+  }
+
+  public static long lowestOneBit (long i) {
+    if (i == 0) {
+      return SIZE;
+    } else {
+      long r = 1;
+      while ((r & i) != 0) {
+        r = r << 1;
+      }
+      return r;
+    }
+  }
+
+  public static int numberOfLeadingZeros(long i) {
+    if (i < 0) {
+      return 0;
+    } else if (i == 0) {
+      return SIZE;
+    } else {
+      return SIZE - 1 - (int)Math.floor(Math.log((double)i) / Math.log(2.0d));
+    }
+  }
+
+  public static int numberOfTrailingZeros(long i) {
+    if (i < 0) {
+      return 0;
+    } else if (i == 0) {
+      return SIZE;
+    } else {
+      int rtn = 0;
+      for (int r = 1; (r & i) != 0; r = r * 2) {
+        rtn++;
+      }
+      return rtn;
+    }
+  }
+
   public static long parseLong(String s) throws NumberFormatException {
     return parseLong(s, 10);
   }
@@ -45,6 +104,51 @@
     return __parseAndValidateLong(s, radix, MIN_VALUE, MAX_VALUE);
   }
 
+  public static long reverse (long i) {
+    long acc = 0;
+    long front = MIN_VALUE;
+    int back = 1;
+    int swing = SIZE - 1;
+    while (swing > 15) {
+      acc = acc | ((i & front) >> swing) | ((i & back) << swing);
+      swing--;
+      front = front >> 1;
+      back = back << 1;
+    }
+    return acc;
+  }
+
+  public static long reverseBytes (long i) {
+    return ((i & 0xffL) << 56) | ((i & 0xff00L) << 40)
+      | ((i & 0xff0000L) << 24) | ((i & 0xff000000L) << 8)
+      | ((i & 0xff00000000L) >> 8) | ((i & 0xff0000000000L) >> 24)
+      | ((i & 0xff000000000000L) >> 40) | ((i & 0xff00000000000000L) >> 56);
+  }
+
+  public static long rotateLeft (long i, int distance) {
+    while (distance-- > 0) {
+      i = i << 1 | ((i < 0) ? 1 : 0);
+    }
+    return i;
+  }
+
+  public static long rotateRight (long i, int distance) {
+    while (distance-- > 0) {
+      i = ((i & 1) == 0 ? 0 : 0x80000000) | i >> 1;
+    }
+    return i;
+  }
+
+  public static int signum (long i) {
+    if (i == 0) {
+      return 0;
+    } else if (i < 0) {
+     return -1;
+    } else {
+      return 1;
+    }
+  }
+
   public static String toBinaryString(long x) {
     if (x == 0) {
       return "0";
@@ -75,7 +179,7 @@
     return String.valueOf(b);
   }
 
-  public static Long valueOf(long i) {
+  public static Long valueOf (long i) {
     if (i > -129 && i < 128) {
       int rebase = (int) i + 128;
       if (boxedValues[rebase] == null) {
diff --git a/user/super/com/google/gwt/emul/java/lang/Math.java b/user/super/com/google/gwt/emul/java/lang/Math.java
index 4d1d6fc..e7ef592 100644
--- a/user/super/com/google/gwt/emul/java/lang/Math.java
+++ b/user/super/com/google/gwt/emul/java/lang/Math.java
@@ -1,12 +1,12 @@
 /*
  * Copyright 2006 Google Inc.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  * use this file except in compliance with the License. You may obtain a copy of
  * the License at
- * 
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -54,26 +54,88 @@
     return Math.atan(x);
   }-*/;
 
+  public static native double atan2 (double y, double x) /*-{
+    return Math.atan2(y,x);
+  }-*/;
+
+  /* NYI: Java 1.5 includes this, but JS doesn't give us the ingredients.: Java 1.5 includes this, but JS doesn't give us the ingredients.
+  public static double cbrt (double x) {
+    return 0;
+  }; */
+
   public static native double ceil(double x) /*-{
     return Math.ceil(x);
   }-*/;
 
+  public static double copySign (double magnitude, double sign) {
+    if (sign < 0) {
+      return (magnitude < 0) ? magnitude : -magnitude;
+    } else {
+      return (magnitude > 0) ? magnitude : -magnitude;
+    }
+  }
+
+  public static float copySign (float magnitude, float sign) {
+    return (float)(copySign((double)magnitude, (double)sign));
+  }
+
   public static native double cos(double x) /*-{
     return Math.cos(x);
   }-*/;
 
+  public static native double cosh(double x) /*-{
+    return (Math.exp(x) + Math.exp(-x)) / 2.0;
+  }-*/;
+
   public static native double exp(double x) /*-{
     return Math.exp(x);
   }-*/;
 
+  public static double expm1 (double d) {
+    if (d == 0.0 || Double.isNaN(d)) {
+      return d; // "a zero with same sign as argument", arg is zero, so...
+    } else if (!Double.isInfinite(d)) {
+      if (d < 0.0d) {
+        return -1.0d;
+      } else {
+        return Double.POSITIVE_INFINITY;
+      }
+    }
+    return exp(d) + 1.0d;
+  }
+
   public static native double floor(double x) /*-{
     return Math.floor(x);
   }-*/;
 
+  /* NYI: Java 1.5 includes this, but JS doesn't give us the ingredients.
+  public static int getExponent (double d) {
+  }
+
+  public static int getExponent (float f) {
+  }
+  */
+
+  public static double hypot(double x, double y) {
+    return sqrt(x * x + y * y);
+  }
+
+  /* NYI: Java 1.5 includes this, but JS doesn't give us the ingredients.
+  public static double IEEEremainder(double f1, double f2) {
+  } */
+
   public static native double log(double x) /*-{
     return Math.log(x);
   }-*/;
 
+  public static double log10 (double x) {
+    return Math.log(x) / Math.log(10);
+  }
+
+  public static double log1p(double x) {
+    return Math.log(x + 1.0d);
+  };
+
   public static double max(double x, double y) {
     return x > y ? x : y;
   }
@@ -106,6 +168,19 @@
     return x < y ? x : y;
   }
 
+  /* NYI: Java 1.5 includes this, but JS doesn't give us the ingredients.
+  public static double nextAfter(double start, double direction) {
+  }
+  public static float nextAfter(float start, float direction) {
+  }
+  public static double nextUp(double start) {
+    return nextAfter(start, 1.0d);
+  }
+  public static float nextUp(float start) {
+    return nextAfter(start,1.0f);
+  }
+  */
+
   public static native double pow(double x, double exp) /*-{
     return Math.pow(x, exp);
   }-*/;
@@ -114,6 +189,18 @@
     return Math.random();
   }-*/;
 
+  public static double rint (double d) {
+    if (Double.isNaN(d)) {
+      return d;
+    } else if (Double.isInfinite(d)) {
+      return d;
+    } else if (d == 0.0d) {
+      return d;
+    } else {
+      return (double)(round(d));
+    }
+  };
+
   public static native long round(double x) /*-{
     return Math.round(x);
   }-*/;
@@ -122,10 +209,53 @@
     return Math.round(x);
   }-*/;
 
+  public static double scalb (double d, int scaleFactor) {
+    if (scaleFactor > 0) {
+      return d * (1 << scaleFactor);
+    } else if (scaleFactor == 0) {
+      return d;
+    } else {
+      return d * 1.0d / (1 << -scaleFactor);
+    }
+  }
+
+  public static float scalb (float f, int scaleFactor) {
+    if (scaleFactor > 0) {
+      return f * (1 << scaleFactor);
+    } else if (scaleFactor == 0) {
+      return f;
+    } else {
+      return f * 1.0f / (1 << -scaleFactor);
+    }
+  }
+
+  public static double signum (double d) {
+    if (d > 0.0d) {
+      return 1.0d;
+    } else if (d < 0.0d) {
+      return -1.0d;
+    } else {
+      return 0.0d;
+    }
+  }
+
+  public static float signum (float f) {
+    if (f > 0.0f) {
+      return 1.0f;
+    } else if (f < 0.0f) {
+      return -1.0f;
+    } else {
+      return 0.0f;
+    }
+  }
   public static native double sin(double x) /*-{
     return Math.sin(x);
   }-*/;
 
+  public static native double sinh(double x) /*-{
+    return Math.sinh(x);
+  }-*/;
+
   public static native double sqrt(double x) /*-{
     return Math.sqrt(x);
   }-*/;
@@ -134,6 +264,10 @@
     return Math.tan(x);
   }-*/;
 
+  public static native double tanh(double x) /*-{
+    return Math.tanh(x);
+  }-*/;
+
   public static double toDegrees(double x) {
     return x * PI_UNDER_180;
   }
@@ -141,4 +275,11 @@
   public static double toRadians(double x) {
     return x * PI_OVER_180;
   }
+
+  /* NYI: Java 1.5 includes this, but JS doesn't give us the ingredients.
+  public static double ulp (double x) {
+  };
+  public static float ulp (float x) {
+  };
+  */
 }
diff --git a/user/super/com/google/gwt/emul/java/lang/Short.java b/user/super/com/google/gwt/emul/java/lang/Short.java
index 20f7197..30fa5a4 100644
--- a/user/super/com/google/gwt/emul/java/lang/Short.java
+++ b/user/super/com/google/gwt/emul/java/lang/Short.java
@@ -1,12 +1,12 @@
 /*
  * Copyright 2007 Google Inc.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  * use this file except in compliance with the License. You may obtain a copy of
  * the License at
- * 
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -22,6 +22,7 @@
 
   public static final short MIN_VALUE = (short) 0x8000;
   public static final short MAX_VALUE = (short) 0x7fff;
+  public static final int SIZE = 16;
 
   // Box values according to JLS - between -128 and 127
   private static Short[] boxedValues = new Short[256];
@@ -46,6 +47,10 @@
     return (short) __parseAndValidateLong(s, radix, MIN_VALUE, MAX_VALUE);
   }
 
+  public static short reverseBytes (short s) {
+    return (short)(((s & 0xff) << 8) | ((s & 0xff00) >> 8));
+  }
+
   public static String toString(short b) {
     return String.valueOf(b);
   }
diff --git a/user/test/com/google/gwt/emultest/EmulSuite.java b/user/test/com/google/gwt/emultest/EmulSuite.java
index 90e7e55..c757ea7 100644
--- a/user/test/com/google/gwt/emultest/EmulSuite.java
+++ b/user/test/com/google/gwt/emultest/EmulSuite.java
@@ -1,12 +1,12 @@
 /*
  * Copyright 2007 Google Inc.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  * use this file except in compliance with the License. You may obtain a copy of
  * the License at
- * 
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -15,9 +15,14 @@
  */
 package com.google.gwt.emultest;
 
+import com.google.gwt.emultest.java.lang.BooleanTest;
+import com.google.gwt.emultest.java.lang.ByteTest;
 import com.google.gwt.emultest.java.lang.CharacterTest;
+import com.google.gwt.emultest.java.lang.DoubleTest;
 import com.google.gwt.emultest.java.lang.IntegerTest;
+import com.google.gwt.emultest.java.lang.LongTest;
 import com.google.gwt.emultest.java.lang.ObjectTest;
+import com.google.gwt.emultest.java.lang.ShortTest;
 import com.google.gwt.emultest.java.lang.StringBufferTest;
 import com.google.gwt.emultest.java.lang.StringTest;
 import com.google.gwt.emultest.java.util.ArraysTest;
@@ -30,24 +35,30 @@
 import junit.framework.TestSuite;
 
 /**
- * Tests all classes in GWT JRE emulation library.
+ * TODO: document me.
  */
 public class EmulSuite {
 
+  /** Note: due to compiler error, only can use one Test Case at a time. */
   public static Test suite() {
     TestSuite suite = new TestSuite("Tests for com.google.gwt.emul.java");
 
     // $JUnit-BEGIN$
     suite.addTestSuite(ArraysTest.class);
+    suite.addTestSuite(BooleanTest.class);
+    suite.addTestSuite(ByteTest.class);
     suite.addTestSuite(HashMapTest.class);
     suite.addTestSuite(StringBufferTest.class);
     suite.addTestSuite(StringTest.class);
     suite.addTestSuite(CharacterTest.class);
     suite.addTestSuite(StackTest.class);
     suite.addTestSuite(IntegerTest.class);
+    suite.addTestSuite(LongTest.class);
+    suite.addTestSuite(DoubleTest.class);
     suite.addTestSuite(DateTest.class);
     suite.addTestSuite(HashSetTest.class);
     suite.addTestSuite(ObjectTest.class);
+    suite.addTestSuite(ShortTest.class);
     // $JUnit-END$
 
     return suite;
diff --git a/user/test/com/google/gwt/emultest/java/lang/BooleanTest.java b/user/test/com/google/gwt/emultest/java/lang/BooleanTest.java
new file mode 100644
index 0000000..f99fbe3
--- /dev/null
+++ b/user/test/com/google/gwt/emultest/java/lang/BooleanTest.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2007 Google Inc.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.emultest.java.lang;
+
+import com.google.gwt.junit.client.GWTTestCase;
+
+/**
+ * Tests for the JRE Boolean type.
+ */
+public class BooleanTest extends GWTTestCase {
+
+  public String getModuleName() {
+    return "com.google.gwt.emultest.EmulSuite";
+  }
+
+  public void testStatics() {
+    // test the "new" 1.5 statics, for now assuming "old" rest works
+    assertEquals(true, Boolean.valueOf(true).booleanValue());
+    assertEquals(false, Boolean.valueOf(false).booleanValue());
+    assertEquals(true, Boolean.valueOf("true").booleanValue());
+    assertEquals(true, Boolean.valueOf("tRuE").booleanValue());
+    assertEquals(false, Boolean.valueOf(null).booleanValue());
+    assertEquals(false, Boolean.valueOf("yes").booleanValue());
+    assertEquals(false, Boolean.valueOf("").booleanValue());
+  }
+}
diff --git a/user/test/com/google/gwt/emultest/java/lang/ByteTest.java b/user/test/com/google/gwt/emultest/java/lang/ByteTest.java
new file mode 100644
index 0000000..14361e0
--- /dev/null
+++ b/user/test/com/google/gwt/emultest/java/lang/ByteTest.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2007 Google Inc.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.emultest.java.lang;
+
+import com.google.gwt.junit.client.GWTTestCase;
+
+/**
+ * Tests for the JRE Byte type.
+ */
+public class ByteTest extends GWTTestCase {
+
+  public String getModuleName() {
+    return "com.google.gwt.emultest.EmulSuite";
+  }
+
+  public void testStatics() {
+    // test the new 1.5 statics... older stuff "assumed to work"
+    assertEquals(0, Byte.valueOf((byte) 0).intValue());
+    assertEquals(127, Byte.valueOf((byte) 127).intValue());
+    assertEquals(-128, Byte.valueOf((byte) -128).intValue());
+    assertEquals(-1, Byte.valueOf((byte) 255).intValue());
+  }
+
+  public void testConstants() {
+    assertEquals(-128, Byte.MIN_VALUE);
+    assertEquals(127, Byte.MAX_VALUE);
+    assertEquals(8, Byte.SIZE);
+  }
+}
diff --git a/user/test/com/google/gwt/emultest/java/lang/DoubleTest.java b/user/test/com/google/gwt/emultest/java/lang/DoubleTest.java
index 4d6edaa..ff33ebe 100644
--- a/user/test/com/google/gwt/emultest/java/lang/DoubleTest.java
+++ b/user/test/com/google/gwt/emultest/java/lang/DoubleTest.java
@@ -19,7 +19,7 @@
 import com.google.gwt.junit.client.GWTTestCase;
 
 /**
- * TODO: document me.
+ * Unit tests for the emulated-in-Javascript Double/double autoboxed types.
  */
 public class DoubleTest extends GWTTestCase {
 
@@ -57,6 +57,9 @@
     assertTrue(Double.NEGATIVE_INFINITY < Double.POSITIVE_INFINITY);
     assertTrue(Double.MIN_VALUE < Double.MAX_VALUE);
     assertFalse(Double.NaN == Double.NaN);
+    assertEquals(64, Double.SIZE);
+    // jdk1.6  assertEquals(Math.getExponent(Double.MAX_VALUE), Double.MAX_EXPONENT);
+    // jdk1.6  assertEquals(Math.getExponent(Double.MIN_NORMAL), Double.MIN_EXPONENT);
   }
 
   public void testParse() {
diff --git a/user/test/com/google/gwt/emultest/java/lang/FloatTest.java b/user/test/com/google/gwt/emultest/java/lang/FloatTest.java
index 5c145d2..4ddbc55 100644
--- a/user/test/com/google/gwt/emultest/java/lang/FloatTest.java
+++ b/user/test/com/google/gwt/emultest/java/lang/FloatTest.java
@@ -19,7 +19,8 @@
 import com.google.gwt.junit.client.GWTTestCase;
 
 /**
- * TODO: document me.
+ * Unit tests for the Javascript emulation of the Float/float autoboxed 
+ * fundamental type.
  */
 public class FloatTest extends GWTTestCase {
 
@@ -57,6 +58,9 @@
     assertTrue(Float.NEGATIVE_INFINITY < Float.POSITIVE_INFINITY);
     assertTrue(Float.MIN_VALUE < Float.MAX_VALUE);
     assertFalse(Float.NaN == Float.NaN);
+    assertEquals(Float.SIZE, 32);
+    // jdk1.6 assertEquals(Float.MIN_EXPONENT, Math.getExponent(Float.MIN_NORMAL));
+    // jdk1.6 assertEquals(Float.MAX_EXPONENT, Math.getExponent(Float.MAX_VALUE));
   }
 
   public void testParse() {
diff --git a/user/test/com/google/gwt/emultest/java/lang/IntegerTest.java b/user/test/com/google/gwt/emultest/java/lang/IntegerTest.java
index a53c08a..1a43fbc 100644
--- a/user/test/com/google/gwt/emultest/java/lang/IntegerTest.java
+++ b/user/test/com/google/gwt/emultest/java/lang/IntegerTest.java
@@ -1,12 +1,12 @@
 /*
  * Copyright 2007 Google Inc.
- *
+ * 
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  * use this file except in compliance with the License. You may obtain a copy of
  * the License at
- *
+ * 
  * http://www.apache.org/licenses/LICENSE-2.0
- *
+ * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -18,7 +18,8 @@
 import com.google.gwt.junit.client.GWTTestCase;
 
 /**
- * TODO: document me.
+ * Unit tests for the Javascript emulation of the Integer/int autoboxed
+ * fundamental type.
  */
 public class IntegerTest extends GWTTestCase {
 
@@ -26,16 +27,6 @@
     return "com.google.gwt.emultest.EmulSuite";
   }
 
-  public void testConstructor() {
-    assertEquals(12345, new Integer(12345).intValue());
-    assertEquals(12345, new Integer("12345").intValue());
-  }
-
-  public void testToString() {
-    assertEquals("12345", new Integer(12345).toString());
-    assertEquals("-12345", new Integer("-12345").toString());
-  }
-
   public void testBadStrings() {
     try {
       new Integer("05abcd");
@@ -57,52 +48,73 @@
     } catch (NumberFormatException e) {
       // Expected behavior
     }
-    
+
     try {
       Integer.parseInt(String.valueOf(Long.MAX_VALUE));
       fail("parseInt should reject numbers greater than the range of int");
     } catch (NumberFormatException e) {
       // Expected behavior
     }
-    
+
     try {
       Integer.parseInt(String.valueOf(Long.MIN_VALUE));
       fail("parseInt should reject numbers less than the range of int");
     } catch (NumberFormatException e) {
       // Expected behavior
     }
-    
+
     try {
-      Integer.parseInt(String.valueOf((long)Integer.MAX_VALUE + 1));
+      Integer.parseInt(String.valueOf((long) Integer.MAX_VALUE + 1));
       fail("parseInt should reject numbers greater than the range of int");
     } catch (NumberFormatException e) {
       // Expected behavior
     }
-    
+
     try {
-      Integer.parseInt(String.valueOf((long)Integer.MIN_VALUE - 1));
+      Integer.parseInt(String.valueOf((long) Integer.MIN_VALUE - 1));
       fail("parseInt should reject numbers less than the range of int");
     } catch (NumberFormatException e) {
       // Expected behavior
     }
   }
 
+  public void testBinaryString() {
+    assertEquals("11000000111001", Integer.toBinaryString(12345));
+    assertEquals("0", Integer.toBinaryString(0));
+    assertEquals("11111111111111111100111111000111",
+        Integer.toBinaryString(-12345));
+  }
+
+  public void testBitCount() {
+    assertEquals(0, Integer.bitCount(0));
+    assertEquals(1, Integer.bitCount(1));
+    assertEquals(32, Integer.bitCount(-1));
+    assertEquals(31, Integer.bitCount(Integer.MAX_VALUE));
+    assertEquals(1, Integer.bitCount(Integer.MIN_VALUE));
+  }
+
   public void testCompareTo() {
     assertEquals(-1, new Integer(12345).compareTo(new Integer(12346)));
     assertEquals(1, new Integer("12345").compareTo(new Integer(12344)));
     assertEquals(0, new Integer("12345").compareTo(new Integer(12345)));
   }
 
-  public void testEquals() {
-    assertFalse(new Integer(12345).equals(new Integer(12346)));
-    assertEquals(new Integer("12345"), new Integer(12345));
+  public void testConstants() {
+    assertEquals(32, Integer.SIZE);
+    assertEquals(0x7fffffff, Integer.MAX_VALUE);
+    assertEquals(0x80000000, Integer.MIN_VALUE);
+  }
+
+  public void testConstructor() {
+    assertEquals(12345, new Integer(12345).intValue());
+    assertEquals(12345, new Integer("12345").intValue());
   }
 
   public void testDecode() {
-    assertEquals(Integer.MAX_VALUE,
-        Integer.decode(String.valueOf(Integer.MAX_VALUE)).intValue());
-    assertEquals(Integer.MIN_VALUE,
-        Integer.decode(String.valueOf(Integer.MIN_VALUE)).intValue());
+    assertEquals(Integer.MAX_VALUE, Integer.decode(
+        String.valueOf(Integer.MAX_VALUE)).intValue());
+    assertEquals(Integer.MIN_VALUE, Integer.decode(
+        String.valueOf(Integer.MIN_VALUE)).intValue());
     assertEquals(12345, Integer.decode("12345").intValue());
     assertEquals(31, Integer.decode("0x1f").intValue());
     assertEquals(-31, Integer.decode("-0X1F").intValue());
@@ -116,10 +128,106 @@
     }
   }
 
+  public void testEquals() {
+    assertFalse(new Integer(12345).equals(new Integer(12346)));
+    assertEquals(new Integer("12345"), new Integer(12345));
+  }
+
   public void testHashCode() {
     assertEquals(1234, new Integer(1234).hashCode());
   }
 
+  public void testHexString() {
+    assertEquals("3039", Integer.toHexString(12345));
+    assertEquals("0", Integer.toHexString(0));
+    assertEquals("ffffcfc7", Integer.toHexString(-12345));
+  }
+
+  public void testHighestOneBit() {
+    assertEquals(0, Integer.highestOneBit(0));
+    assertEquals(Integer.MIN_VALUE, Integer.highestOneBit(-1));
+    assertEquals(Integer.MIN_VALUE, Integer.highestOneBit(-256));
+    assertEquals(1, Integer.highestOneBit(1));
+    assertEquals(0x80, Integer.highestOneBit(0x80));
+    assertEquals(0x40000000, Integer.highestOneBit(Integer.MAX_VALUE));
+  }
+
+  public void testLowestOneBit() {
+    assertEquals(0, Integer.lowestOneBit(0));
+    assertEquals(1, Integer.lowestOneBit(-1));
+    assertEquals(0x100, Integer.lowestOneBit(-256));
+    assertEquals(1, Integer.lowestOneBit(1));
+    assertEquals(0x80, Integer.lowestOneBit(0x80));
+    assertEquals(0x80000000, Integer.lowestOneBit(Integer.MIN_VALUE));
+  }
+
+  public void testNumberOfLeadingZeros() {
+    assertEquals(32, Integer.numberOfLeadingZeros(0));
+    assertEquals(31, Integer.numberOfLeadingZeros(1));
+    assertEquals(0, Integer.numberOfLeadingZeros(-1));
+    assertEquals(16, Integer.numberOfLeadingZeros(0x8000));
+    assertEquals(1, Integer.numberOfLeadingZeros(Integer.MAX_VALUE));
+    assertEquals(0, Integer.numberOfLeadingZeros(Integer.MIN_VALUE));
+    assertEquals(0, Integer.numberOfLeadingZeros(-0x8000));
+  }
+
+  public void testNumberOfTrailingZeros() {
+    assertEquals(32, Integer.numberOfTrailingZeros(0));
+    assertEquals(0, Integer.numberOfTrailingZeros(1));
+    assertEquals(0, Integer.numberOfTrailingZeros(-1));
+    assertEquals(15, Integer.numberOfTrailingZeros(0x8000));
+    assertEquals(0, Integer.numberOfTrailingZeros(Integer.MAX_VALUE));
+    assertEquals(31, Integer.numberOfTrailingZeros(Integer.MIN_VALUE));
+    assertEquals(4, Integer.numberOfTrailingZeros(-0x7ff0));
+  }
+
+  public void testReverse() {
+    assertEquals(0, Integer.reverse(0));
+    assertEquals(-1, Integer.reverse(-1));
+    assertEquals(Integer.MIN_VALUE, Integer.reverse(1));
+    assertEquals(1, Integer.reverse(Integer.MIN_VALUE));
+    assertEquals(0xaaaaaaaa, Integer.reverse(0x55555555));
+  }
+
+  public void testReverseBytes() {
+  }
+
+  public void testRotateLeft() {
+    assertEquals(0, Integer.rotateLeft(0, 4));
+    assertEquals(0x2, Integer.rotateLeft(1, 1));
+    assertEquals(0x10, Integer.rotateLeft(1, 4));
+    assertEquals(-1, Integer.rotateLeft(-1, 4));
+    assertEquals(Integer.MIN_VALUE, Integer.rotateLeft(0x40000000, 1));
+    assertEquals(1, Integer.rotateLeft(Integer.MIN_VALUE, 1));
+  }
+
+  public void testRotateRight() {
+    assertEquals(0, Integer.rotateRight(0, 4));
+    assertEquals(Integer.MIN_VALUE, Integer.rotateRight(1, 1));
+    assertEquals(0x10000000, Integer.rotateRight(1, 4));
+    assertEquals(-1, Integer.rotateRight(-1, 4));
+  }
+
+  public void testSignum() {
+    assertEquals(0, Integer.signum(0));
+    assertEquals(1, Integer.signum(1));
+    assertEquals(-1, Integer.signum(-1));
+    assertEquals(1, Integer.signum(Integer.MAX_VALUE));
+    assertEquals(-1, Integer.signum(Integer.MIN_VALUE));
+  }
+
+  public void testStaticValueOf() {
+    assertEquals(Integer.MIN_VALUE,
+        Integer.valueOf(Integer.MIN_VALUE).intValue());
+    assertEquals(Integer.MAX_VALUE,
+        Integer.valueOf(Integer.MAX_VALUE).intValue());
+  }
+
+  public void testToString() {
+    assertEquals("12345", new Integer(12345).toString());
+    assertEquals("-12345", new Integer("-12345").toString());
+  }
+
   public void testValueOf() {
     assertEquals(new Integer(12345), Integer.valueOf("12345"));
     assertEquals(new Integer(1865), Integer.valueOf("12345", 6));
@@ -127,30 +235,20 @@
     assertEquals(1865, Integer.parseInt("12345", 6));
   }
 
-  public void testHexString() {
-    assertEquals("3039", Integer.toHexString(12345));
-    assertEquals("0", Integer.toHexString(0));
-    assertEquals("ffffcfc7", Integer.toHexString(-12345));
-  }
-
-  public void testBinaryString() {
-    assertEquals("11000000111001", Integer.toBinaryString(12345));
-    assertEquals("0", Integer.toBinaryString(0));
-    assertEquals("11111111111111111100111111000111", Integer.toBinaryString(-12345));
-  }
-
   public void testXValue() {
-    assertEquals("short",(short) 12345, new Integer(12345).shortValue());
+    assertEquals("short", (short) 12345, new Integer(12345).shortValue());
     assertEquals("long", 1234567890L, new Integer(1234567890).longValue());
-    assertEquals("double", 12345d, new Integer(12345).doubleValue(),0.001);
-    assertEquals("float",12345f, new Integer(12345).floatValue(),0.01);
+    assertEquals("double", 12345d, new Integer(12345).doubleValue(), 0.001);
+    assertEquals("float", 12345f, new Integer(12345).floatValue(), 0.01);
     assertEquals("byte", (byte) 123, new Integer(123).byteValue());
-    assertEquals("integer",123, new Integer(123).intValue());
-    assertEquals("short overflow", (short) 10713, new Integer(1234512345).shortValue());
-    assertEquals("double2", 1234512345d, new Integer(1234512345).doubleValue(), 0.001);
+    assertEquals("integer", 123, new Integer(123).intValue());
+    assertEquals("short overflow", (short) 10713,
+        new Integer(1234512345).shortValue());
+    assertEquals("double2", 1234512345d, new Integer(1234512345).doubleValue(),
+        0.001);
     // Invalid test right now; we don't coerce to single precision
-    // assertEquals("float2",1234512345f, new Integer(1234512345).floatValue(),0.001);
-    assertEquals("byte overflow",(byte) -13, new Integer(123123).byteValue());
+    // assertEquals("float2",1234512345f, new
+    // Integer(1234512345).floatValue(),0.001);
+    assertEquals("byte overflow", (byte) -13, new Integer(123123).byteValue());
   }
-
 }
diff --git a/user/test/com/google/gwt/emultest/java/lang/ShortTest.java b/user/test/com/google/gwt/emultest/java/lang/ShortTest.java
new file mode 100644
index 0000000..d23d5cd
--- /dev/null
+++ b/user/test/com/google/gwt/emultest/java/lang/ShortTest.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2007 Google Inc.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.emultest.java.lang;
+
+import com.google.gwt.junit.client.GWTTestCase;
+
+/**
+ * Tests for the JRE Short type.
+ */
+public class ShortTest extends GWTTestCase {
+
+  public String getModuleName() {
+    return "com.google.gwt.emultest.EmulSuite";
+  }
+
+  public void testConstants() {
+    assertEquals(16, Short.SIZE);
+    assertEquals((short) 0x7fff, Short.MAX_VALUE);
+    assertEquals((short) 0x8000, Short.MIN_VALUE);
+  }
+
+  public void testReverseBytes() {
+    assertEquals(0x1122, Short.reverseBytes((short) 0x2211));
+    assertEquals(0, Short.reverseBytes((short) 0));
+  }
+
+  public void testStaticValueOf() {
+    assertEquals(Short.MIN_VALUE, Short.valueOf(Short.MIN_VALUE).shortValue());
+    assertEquals(Short.MAX_VALUE, Short.valueOf(Short.MAX_VALUE).shortValue());
+  }
+}