tests/libjava-mauve/src/gnu/testlet/java/lang/Double/DoubleTest.java
branchjk_new_structure
changeset 1541 75c2e24dea9a
parent 1540 92ac284961c1
child 1542 be11db817bcf
equal deleted inserted replaced
1540:92ac284961c1 1541:75c2e24dea9a
     1 /* Copyright (C) 1999, 2002 Hewlett-Packard Company
       
     2 
       
     3    This file is part of Mauve.
       
     4 
       
     5    Mauve is free software; you can redistribute it and/or modify
       
     6    it under the terms of the GNU General Public License as published by
       
     7    the Free Software Foundation; either version 2, or (at your option)
       
     8    any later version.
       
     9 
       
    10    Mauve is distributed in the hope that it will be useful,
       
    11    but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    13    GNU General Public License for more details.
       
    14 
       
    15    You should have received a copy of the GNU General Public License
       
    16    along with Mauve; see the file COPYING.  If not, write to
       
    17    the Free Software Foundation, 59 Temple Place - Suite 330,
       
    18    Boston, MA 02111-1307, USA.
       
    19 */
       
    20 
       
    21 // Tags: JDK1.0
       
    22 
       
    23 package gnu.testlet.java.lang.Double;
       
    24 import gnu.testlet.Testlet;
       
    25 import gnu.testlet.TestHarness;
       
    26 
       
    27 public class DoubleTest implements Testlet
       
    28 {
       
    29 
       
    30   protected static TestHarness harness;
       
    31 	public void test_Basics()
       
    32 	{
       
    33 		double min1 = 5e-324;
       
    34 		double min2 = Double.MIN_VALUE;
       
    35 		double max1 = 1.7976931348623157e+308;
       
    36 		double max2 = Double.MAX_VALUE;
       
    37 		double ninf1 = -1.0/0.0;
       
    38 		double ninf2 = Double.NEGATIVE_INFINITY;
       
    39 		double pinf1 = 1.0/0.0;
       
    40 		double pinf2 = Double.POSITIVE_INFINITY;
       
    41 		Double nan1 = new Double(0.0/0.0);
       
    42 		Double nan2 = new Double(Double.NaN);
       
    43 
       
    44 		if ( min1 != min2 ) {
       
    45 		    harness.fail("test_Basics - 1a");
       
    46 		    System.out.println("Expected: " + min1);
       
    47 		    System.out.println("Got: " + min2);
       
    48 		}
       
    49 		if ( max1 != max2 ) {
       
    50 		    harness.fail("test_Basics - 1b");
       
    51 		    System.out.println("Expected: " + max1);
       
    52 		    System.out.println("Got: " + max2);
       
    53 		}
       
    54 		if (ninf1 != ninf2) {
       
    55 		    harness.fail("test_Basics - 1c");
       
    56 		    System.out.println("Expected: " + ninf1);
       
    57 		    System.out.println("Got: " + ninf2);
       
    58 		}
       
    59 		if (pinf1 != pinf2) {
       
    60 		    harness.fail("test_Basics - 1d");
       
    61 		    System.out.println("Expected: " + pinf1);
       
    62 		    System.out.println("Got: " + pinf2);
       
    63 		}
       
    64 		if (!nan2.equals(nan1) ) {
       
    65 		    harness.fail("test_Basics CYGNUS: NaN.equals - 1e");
       
    66 		    System.out.println("Expected: " + nan1);
       
    67 		    System.out.println("Got: " + nan2);
       
    68 		}
       
    69 
       
    70 		Double i1 = new Double(100.5);
       
    71 
       
    72 		harness.check(!( i1.doubleValue() != 100.5 ), 
       
    73 			"test_Basics - 2" );
       
    74 
       
    75 
       
    76 		try {
       
    77 		harness.check(!( (new Double("234.34")).doubleValue() != 234.34 ), 
       
    78 			"test_Basics - 3" );
       
    79 		}
       
    80 		catch ( NumberFormatException e )
       
    81 		{
       
    82 			harness.fail("test_Basics - 3" );
       
    83 		}
       
    84 
       
    85 		try {
       
    86 		harness.check(!( (new Double("1.4e-45")).doubleValue() != 1.4e-45 ), 
       
    87 			"test_Basics - 4" );
       
    88 		}
       
    89 		catch ( NumberFormatException e )
       
    90 		{
       
    91 			harness.fail("test_Basics - 4" );
       
    92 		}
       
    93 
       
    94 		try {
       
    95 		    new Double("babu");
       
    96 			harness.fail("test_Basics - 5" );
       
    97 		}
       
    98 		catch ( NumberFormatException e )
       
    99 		{
       
   100 		}
       
   101 
       
   102 		harness.check(!( (new Double(3.4)).doubleValue() != 3.4 ), 
       
   103 			"test_Basics - 6" );
       
   104 
       
   105 
       
   106 		Double nan = new Double(Double.NaN );
       
   107 		harness.check(!( !nan.isNaN()), 
       
   108 			"test_Basics - 7" );
       
   109 		
       
   110 		harness.check(!( (new Double(10.0f)).isNaN()), 
       
   111 			"test_Basics - 8" );
       
   112 
       
   113 		harness.check(!( !Double.isNaN( Double.NaN )), 
       
   114 			"test_Basics - 9" );
       
   115 
       
   116 		harness.check(!( !(new Double(Double.POSITIVE_INFINITY)).isInfinite()), 
       
   117 			"test_Basics - 10" );
       
   118 
       
   119 		harness.check(!( !(new Double(Double.NEGATIVE_INFINITY)).isInfinite()), 
       
   120 			"test_Basics - 11" );
       
   121 		harness.check(!( !( Double.isInfinite( Double.NEGATIVE_INFINITY))), 
       
   122 			"test_Basics - 12" );
       
   123 		harness.check(!( !( Double.isInfinite( Double.POSITIVE_INFINITY))), 
       
   124 			"test_Basics - 13" );
       
   125 		harness.check(!( 0.0 - 0.0 != 0.0), 
       
   126 			"test_Basics - 14" );
       
   127 		harness.check(!( 0.0 + 0.0 != 0.0), 
       
   128 			"test_Basics - 15" );
       
   129 		harness.check(!( 0.0 + -0.0 != 0.0), 
       
   130 			"test_Basics - 16" );
       
   131 		harness.check(!( 0.0 - -0.0 != 0.0), 
       
   132 			"test_Basics - 17" );
       
   133 		harness.check(!( -0.0 - 0.0 != -0.0), 
       
   134 			"test_Basics - 18" );
       
   135 		harness.check(!( -0.0 + 0.0 != 0.0), 
       
   136 			"test_Basics - 19" );
       
   137 		harness.check(!( -0.0 + -0.0 != -0.0), 
       
   138 			"test_Basics - 20" );
       
   139 		harness.check(!( -0.0 - -0.0 != 0.0), 
       
   140 			"test_Basics - 21" );
       
   141 
       
   142 		harness.check(!( !"0.0".equals(0.0 - 0.0 +"" )), 
       
   143 			"test_Basics - 22" );
       
   144 
       
   145 	}
       
   146 
       
   147 	public void test_toString()
       
   148 	{
       
   149 		harness.check(!( !( new Double(123.0)).toString().equals("123.0")), 
       
   150 			"test_toString - 1" );
       
   151 		harness.check(!( !( new Double(-44.5343)).toString().equals("-44.5343")), 
       
   152 			"test_toString - 2" );
       
   153 
       
   154 		harness.check(!( !Double.toString( 23.04 ).equals ("23.04" )), 
       
   155 			"test_toString - 3" );
       
   156 
       
   157 		harness.check(!( !Double.toString( Double.NaN ).equals ("NaN" )), 
       
   158 			"test_toString - 4" );
       
   159 
       
   160 		harness.check(!( !Double.toString( Double.POSITIVE_INFINITY ).equals ("Infinity" )), 
       
   161 			"test_toString - 5" );
       
   162 		harness.check(!( !Double.toString( Double.NEGATIVE_INFINITY ).equals ("-Infinity" )), 
       
   163 			"test_toString - 6" );
       
   164 
       
   165 		harness.check(!( !Double.toString( 0.0 ).equals ("0.0" )), 
       
   166 			"test_toString - 7" );
       
   167 
       
   168 		String str;
       
   169 
       
   170 		str = Double.toString( -0.0 );
       
   171 		harness.check(!( !str.equals ("-0.0" )), 
       
   172 			"test_toString - 8" );
       
   173 
       
   174 		str = Double.toString( -9412128.34 );
       
   175 		harness.check(!( !str.equals ("-9412128.34" )), 
       
   176 			"test_toString - 9" );
       
   177 
       
   178 		// The following case fails for some Sun JDKs (e.g. 1.3.1
       
   179 		// and 1.4.0) where toString(0.001) returns "0.0010".  This
       
   180 		// is contrary to the JDK 1.4 javadoc.  This particular
       
   181 		// case has been noted as a comment to Sun Java bug #4642835
       
   182 		str = Double.toString( 0.001 );
       
   183 		if ( !Double.toString( 0.001 ).equals ("0.001" )) {
       
   184 			harness.fail("test_toString - 10" );
       
   185 			System.out.println("Expected: " + "0.001");
       
   186 			System.out.println("Got: " + Double.toString(0.001));
       
   187 		}
       
   188 
       
   189 		str = Double.toString( 1e4d );
       
   190 		if ( !Double.toString( 1e4d ).equals ("10000.0" )) {
       
   191 			harness.fail("test_toString - 11" );
       
   192 			System.out.println("Expected: " + "10000.0");
       
   193 			System.out.println("Got: " + Double.toString(1e4d));
       
   194 		}
       
   195 
       
   196 		str = Double.toString(33333333.33 );
       
   197 		if ( !(new Double( str)).equals(new Double(33333333.33))) {
       
   198 			harness.fail("test_toString - 12" );
       
   199 			System.out.println("Expected: " + 
       
   200 				(new Double(33333333.33)).toString());
       
   201 			System.out.println("Got: " + 
       
   202 				(new Double(str)).toString());
       
   203 		}
       
   204 		str = Double.toString(-123232324253.32 );
       
   205 		if ( !(new Double( str)).equals(new Double(-123232324253.32))) {
       
   206 			harness.fail("test_toString - 13" );
       
   207 			System.out.println("Expected: " + 
       
   208 				(new Double(-123232324253.32)).toString());
       
   209 			System.out.println("Got: " + 
       
   210 				(new Double(str)).toString());
       
   211 		}
       
   212 		str = Double.toString(1.243E10);
       
   213 		if ( !(new Double( str)).equals(new Double(1.243E10))) {
       
   214 			harness.fail("test_toString - 14" );
       
   215 			System.out.println("Expected: " + 
       
   216 				(new Double(1.243E10)).toString());
       
   217 			System.out.println("Got: " + 
       
   218 				(new Double(str)).toString());
       
   219 		}
       
   220 		str = Double.toString(Double.MIN_VALUE);
       
   221 		if ( !str.equals("4.9E-324")) {
       
   222 			harness.fail("test_toString - 15" );
       
   223 			harness.debug("Expected: 4.9E-324");
       
   224 			harness.debug("Got: " + str);
       
   225 		}
       
   226 
       
   227 		/*
       
   228 		str = Double.toString(-23.43E33);
       
   229 		if ( !(new Double( str)).equals(new Double(-23.43E33)))
       
   230 			harness.fail("test_toString - 16" );
       
   231 		*/
       
   232 		
       
   233 	}
       
   234 
       
   235 	public void test_equals()
       
   236 	{
       
   237 		Double i1 = new Double(2334.34E4);
       
   238 		Double i2 = new Double(-2334.34E4);
       
   239 
       
   240 		harness.check(!( !i1.equals( new Double(2334.34E4))), 
       
   241 			"test_equals - 1" );
       
   242 		harness.check(!( !i2.equals( new Double(-2334.34E4))), 
       
   243 			"test_equals - 2" );
       
   244 
       
   245 		
       
   246 		harness.check(!( i1.equals( i2 )), 
       
   247 			"test_equals - 3" );
       
   248 
       
   249 		harness.check(!( i1.equals(null)), 
       
   250 			"test_equals - 4" );
       
   251 
       
   252 		double n1 = Double.NaN;
       
   253 		double n2 = Double.NaN;
       
   254 		harness.check(!( n1 == n2 ), 
       
   255 			"test_equals - 5" );
       
   256 
       
   257 		Double flt1 = new Double( Double.NaN);
       
   258 		Double flt2 = new Double( Double.NaN);
       
   259 		harness.check(!( !flt1.equals(flt2)), 
       
   260 			"test_equals CYGNUS: NaN.equals - 6" );
       
   261 
       
   262 		harness.check(!( 0.0 != -0.0 ), 
       
   263 			"test_equals - 7" );
       
   264 
       
   265 		Double pzero = new Double( 0.0 );
       
   266 		Double nzero = new Double( -0.0 );
       
   267 
       
   268 		harness.check(!( pzero.equals(nzero) ), 
       
   269 			"test_equals CYGNUS: Double.equals - 8" );
       
   270 
       
   271 	}
       
   272 
       
   273 
       
   274 	public void test_hashCode( )
       
   275 	{
       
   276 		Double flt1 = new Double(3.4028235e+38);
       
   277 		long lng1 = Double.doubleToLongBits( 3.4028235e+38);
       
   278 
       
   279 		harness.check(!( flt1.hashCode() != (int) ( lng1^(lng1>>>32)) ), 
       
   280 			"test_hashCode - 1");
       
   281 
       
   282 		Double flt2 = new Double( -2343323354.0 );
       
   283 		long lng2 = Double.doubleToLongBits( -2343323354.0 );
       
   284 
       
   285 		harness.check(!( flt2.hashCode() != (int) ( lng2^(lng2>>>32)) ), 
       
   286 			"test_hashCode - 2");
       
   287 	}
       
   288 
       
   289 	public void test_intValue( )
       
   290 	{
       
   291 		Double b1 = new Double(3.4e+32);
       
   292 		Double b2 = new Double(-23.45);
       
   293 
       
   294 		int i1 = b1.intValue();
       
   295 		int i2 = b2.intValue();
       
   296 
       
   297 		harness.check(!( i1 != (int) 3.4e+32),  
       
   298 			"test_intValue CYGNUS: Float to int conversions - 1" );
       
   299 
       
   300 		harness.check(!( i2 != (int) -23.45 ),  
       
   301 			"test_intValue - 2" );
       
   302 		Double b3 = new Double(3000.54);
       
   303 		harness.check(!( b3.intValue() != 3000  ),  
       
   304 			"test_intValue - 3" );
       
   305 		Double b4 = new Double(32735.3249);
       
   306 		harness.check(!( b4.intValue() != 32735  ),  
       
   307 			"test_intValue - 4" );
       
   308 		Double b5 = new Double(-32735.3249);
       
   309 		harness.check(!( b5.intValue() != -32735  ),  
       
   310 			"test_intValue - 5" );
       
   311 		Double b6 = new Double(-32735.3249);
       
   312 		harness.check(!( b6.intValue() != -32735  ),  
       
   313 			"test_intValue - 6" );
       
   314 		Double b7 = new Double(0.0);
       
   315 		harness.check(!( b7.intValue() != 0  ),  
       
   316 			"test_intValue - 7" );
       
   317 	}
       
   318 
       
   319 	public void test_longValue( )
       
   320 	{
       
   321 		Double b1 = new Double(3.4e+32);
       
   322 		Double b2 = new Double(-23.45);
       
   323 
       
   324 		harness.check(!( b1.longValue() != (long) 3.4e+32),  
       
   325 			"test_longValue CYGNUS: Float to int conversions - 1" );
       
   326 
       
   327 		harness.check(!( b2.longValue() != (long) -23.45 ),  
       
   328 			"test_longValue - 2" );
       
   329 	}
       
   330 
       
   331 	public void test_DoubleValue( )
       
   332 	{
       
   333 		Double b1 = new Double(3276.34);
       
   334 		Double b2 = new Double(-3276.32);
       
   335 
       
   336 		harness.check(!( b1.doubleValue() != 3276.34 ),  
       
   337 			"test_DoubleValue - 1" );
       
   338 
       
   339 		harness.check(!( b2.doubleValue() != -3276.32 ),  
       
   340 			"test_DoubleValue - 2" );
       
   341 	}
       
   342 
       
   343 	public void test_doubleValue( )
       
   344 	{
       
   345 		Double b1 = new Double(0.0);
       
   346 		Double b2 = new Double(30.0);
       
   347 
       
   348 		harness.check(!( b1.doubleValue() != 0.0 ),  
       
   349 			"test_doubleValue - 1" );
       
   350 
       
   351 		harness.check(!( b2.doubleValue() != 30.0 ),  
       
   352 			"test_doubleValue - 2" );
       
   353 	}
       
   354 
       
   355 	public void test_floatValue( )
       
   356 	{
       
   357 		Double b1 = new Double(0.0);
       
   358 		Double b2 = new Double(30.0);
       
   359 
       
   360 		harness.check(!( b1.floatValue() != 0.0f ),  
       
   361 			"test_floatValue - 1" );
       
   362 
       
   363 		harness.check(!( b2.floatValue() != 30.0f ),  
       
   364 			"test_floatValue - 2" );
       
   365 	}
       
   366 
       
   367 	public void test_valueOf( )
       
   368 	{
       
   369 		try {
       
   370 			Double.valueOf(null);
       
   371 			harness.fail("test_valueOf - 1" );
       
   372 		} 
       
   373 		catch ( NumberFormatException nfe )
       
   374 		  {harness.check(false, "test_valueOf null should throw NullPointerException");}
       
   375                 catch ( NullPointerException e )
       
   376 		  {harness.check(true, "test_valueOf null");}
       
   377 
       
   378 		try {
       
   379 			Double.valueOf("Kona");
       
   380 			harness.fail("test_valueOf - 2" );
       
   381 		}catch( NumberFormatException e) {}
       
   382 
       
   383 		harness.check(!( Double.valueOf( "3.4e+32" ).doubleValue() != 3.4e+32 ),  
       
   384 			"test_valueOf - 3" );
       
   385 
       
   386 		harness.check(!( Double.valueOf(" -23.45    ").doubleValue() != -23.45 ),  
       
   387 			"test_valueOf - 4" );
       
   388 	}
       
   389 
       
   390 	public void test_parseDouble( )
       
   391 	{
       
   392 		try {
       
   393 			Double.parseDouble(null);
       
   394 			harness.fail("test_parseDouble - 1" );
       
   395 		} 
       
   396 		catch ( NumberFormatException nfe )
       
   397 		  {harness.check(false, "test_parseDouble null should throw NullPointerException");}
       
   398                 catch ( NullPointerException e )
       
   399 		  {harness.check(true, "test_parseDouble null");}
       
   400 
       
   401 		try {
       
   402 			Double.parseDouble("Kona");
       
   403 			harness.fail("test_parseDouble - 2" );
       
   404 		}catch( NumberFormatException e) {}
       
   405 
       
   406 		harness.check(!( Double.parseDouble( "3.4e+32" ) != 3.4e+32 ),  
       
   407 			"test_parseDouble - 3" );
       
   408 
       
   409 		harness.check(!( Double.parseDouble(" -23.45    ") != -23.45 ),  
       
   410 			"test_parseDouble - 4" );
       
   411 	}
       
   412 
       
   413 	public void test_doubleToLongBits()
       
   414 	{
       
   415 		harness.check(!( Double.doubleToLongBits( Double.POSITIVE_INFINITY ) != 0x7ff0000000000000L ), 
       
   416 			"test_doubleToLongBits - 1" );
       
   417 		harness.check(!( Double.doubleToLongBits( Double.NEGATIVE_INFINITY ) != 0xfff0000000000000L ), 
       
   418 			"test_doubleToLongBits - 2" );
       
   419 		
       
   420 		long nanval = Double.doubleToLongBits( Double.NaN ); 
       
   421 		harness.check(!( nanval != 0x7ff8000000000000L ), 
       
   422 			"test_doubleToLongBits CYGNUS: NaN.doubleToLongBits" );
       
   423 
       
   424 		long i1 = Double.doubleToLongBits(3.4e+32f);
       
   425 		long i2 = Double.doubleToLongBits(-34.56f);
       
   426 
       
   427 		long sign1 = i1 & 0x8000000000000000L ;
       
   428 		long sign2 = i2 & 0x8000000000000000L ;
       
   429 
       
   430 		long exp1 = i1 & 0x7ff0000000000000L ;
       
   431 		long exp2 = i2 & 0x7ff0000000000000L ;
       
   432 
       
   433 		long man1 = i1 & 0x000fffffffffffffL ;
       
   434 		long man2 = i2 & 0x000fffffffffffffL ;
       
   435 
       
   436 		harness.check(!(sign1 != 0 ), 
       
   437 			"test_doubleToLongBits - 4" );
       
   438 
       
   439 		harness.check(!( sign2 != 0x8000000000000000L ), 
       
   440 			"test_doubleToLongBits - 5" );
       
   441 
       
   442 		harness.check(!( exp1 != 5093571178556030976L ), 
       
   443 			"test_doubleToLongBits - 6" );
       
   444 
       
   445 		harness.check(!( exp2 != 4629700416936869888L ), 
       
   446 			"test_doubleToLongBits - 7" );
       
   447 
       
   448 		harness.check(!( man1 != 214848222789632L  ), 
       
   449 			"test_doubleToLongBits - 8" );
       
   450 
       
   451 		harness.check(!( man2 != 360288163463168L ), 
       
   452 			"test_doubleToLongBits - 9" );
       
   453 
       
   454 	}
       
   455 
       
   456 	public void test_longBitsToDouble( )
       
   457 	{
       
   458 		harness.check(!( Double.longBitsToDouble( 0x7ff0000000000000L) != Double.POSITIVE_INFINITY ), 
       
   459 			"test_longBitsToDouble - 1" );
       
   460 		harness.check(!( Double.longBitsToDouble( 0xfff0000000000000L ) != Double.NEGATIVE_INFINITY ), 
       
   461 			"test_longBitsToDouble - 2" );
       
   462 
       
   463 
       
   464 		harness.check(!( !Double.isNaN(Double.longBitsToDouble( 0xfff8000000000000L  ))), 
       
   465 			"test_longBitsToDouble - 3" );
       
   466 
       
   467 		harness.check(!( !Double.isNaN(Double.longBitsToDouble( 0x7ffffff000000000L ))), 
       
   468 			"test_longBitsToDouble - 4" );
       
   469 
       
   470 		harness.check(!( !Double.isNaN(Double.longBitsToDouble( 0xfff8000020000001L ))), 
       
   471 			"test_longBitsToDouble - 5" );
       
   472 
       
   473 		harness.check(!( !Double.isNaN(Double.longBitsToDouble( 0xfffffffffffffff1L ))), 
       
   474 			"test_longBitsToDouble - 6" );
       
   475 
       
   476 		double fl1 = Double.longBitsToDouble( 0x34343f33 );
       
   477 		
       
   478 		if ( Double.doubleToLongBits(fl1) != 0x34343f33 ) {
       
   479 			harness.fail("test_longBitsToDouble - 7" );
       
   480 			System.out.println("Expected: " + Long.toHexString(0x34343f33));
       
   481 			System.out.println("Got: " + Long.toHexString(Double.doubleToLongBits(fl1)));
       
   482 		}
       
   483 
       
   484 		harness.check(!( Double.doubleToLongBits( Double.longBitsToDouble(0x33439943)) != 0x33439943 ), 
       
   485 			"test_longBitsToDouble - 8");
       
   486 	}
       
   487 
       
   488 	public void check_remainder( double val, double val1 , 
       
   489 					double ret , int errno )
       
   490 	{
       
   491 		double res = val % val1;
       
   492 		harness.check(!( res < ret - 0.001 || res > ret + 0.001 ), 
       
   493 			"test_remainder " +  errno );
       
   494 	}
       
   495 
       
   496 	public void check_remainder_NaN( double val, double val1 , 
       
   497 					int errno )
       
   498 	{
       
   499 		double res = val % val1;
       
   500 		if (!Double.isNaN(res)) {
       
   501 		    harness.fail("test_remainder " +
       
   502 								    errno);
       
   503 		} 
       
   504 	}
       
   505 
       
   506 	public void test_remainder( )
       
   507 	{
       
   508 		check_remainder(15.2 , 1.0 , 0.2, 1 );
       
   509 		check_remainder(2345.2432 , 1.2 ,0.44319999999997 , 2 );
       
   510 		check_remainder(20.56 , 1.87 ,1.8600000000000 , 3 );
       
   511 		check_remainder(0.0 , 1.2 , 0.00000000000000 , 4 );
       
   512 		check_remainder(1000 , 10 , 0.00000000000000 , 5 );
       
   513 		check_remainder(234.332 , 134.34 , 99.992000000000 , 6 );
       
   514 		check_remainder(1.0 , 1.0, 0.0 , 7 );
       
   515 		check_remainder(45.0 , 5.0, 0.0 , 8  );
       
   516 		check_remainder(1.25 , 0.50 , 0.25 , 9  );
       
   517 		check_remainder(12345.678, 1234.5678, 1234.5678000000 , 10 );
       
   518                
       
   519                 if (!System.getProperty("os.name").equals("VxWorks")){
       
   520                   // bug EJWcr00686, has not been fixed yet.
       
   521                   // Test is disabled for smallvm 2.0.1 release.
       
   522                   check_remainder(Double.MAX_VALUE , Double.MIN_VALUE , 0.00000000000000 , 11 );
       
   523                 }
       
   524 		
       
   525                 check_remainder(0.0 , 999.99, 0.00000000000000 , 12 );
       
   526 		check_remainder(123.0 , 25.0 , 23.0 , 13 );
       
   527 		check_remainder(15.0 , 1.5 , 0.00 , 14 );
       
   528 		check_remainder_NaN(Double.NaN, 1.5 , 15 );
       
   529 		check_remainder_NaN(1.5, Double.NaN, 16 );
       
   530 		check_remainder_NaN(Double.NaN, 0, 17 );
       
   531 		check_remainder_NaN(0, Double.NaN, 18 );
       
   532 		check_remainder_NaN(Double.POSITIVE_INFINITY, 1.5, 19 );
       
   533 		check_remainder_NaN(Double.NEGATIVE_INFINITY, 1.5, 20 );
       
   534 		check_remainder_NaN(1.5, 0, 21 );
       
   535 		check_remainder_NaN(Double.POSITIVE_INFINITY, 0, 22 );
       
   536 		check_remainder_NaN(Double.NEGATIVE_INFINITY, 0, 23 );
       
   537 		// EJWcr00505
       
   538                 check_remainder(15.0 , Double.POSITIVE_INFINITY, 15.0 , 24 );
       
   539                 check_remainder(-15.0 , Double.POSITIVE_INFINITY, -15.0 , 25 );
       
   540                 check_remainder(0.0 , Double.POSITIVE_INFINITY, 0.0 , 26 );
       
   541                 check_remainder(-0.0 , Double.POSITIVE_INFINITY, -0.0 , 27 );
       
   542                 check_remainder(0.1 , Double.POSITIVE_INFINITY, 0.1 , 28 );
       
   543                 check_remainder(-0.1 , Double.POSITIVE_INFINITY, -0.1 , 29 );
       
   544 
       
   545                 check_remainder(15.0 , Double.NEGATIVE_INFINITY, 15.0 , 30 );
       
   546                 check_remainder(-15.0 , Double.NEGATIVE_INFINITY, -15.0 , 31 );
       
   547                 check_remainder(0.0 , Double.NEGATIVE_INFINITY, 0.0 , 32 );
       
   548                 check_remainder(-0.0 , Double.NEGATIVE_INFINITY, -0.0 , 33 );
       
   549                 check_remainder(0.1 , Double.NEGATIVE_INFINITY, 0.1 , 34 );
       
   550                 check_remainder(-0.1 , Double.NEGATIVE_INFINITY, -0.1 , 35 );
       
   551                
       
   552 
       
   553 	}
       
   554 
       
   555 	public void test_shortbyteValue()
       
   556 	{
       
   557 		Double d1 = new Double( 123.35 );
       
   558 		Double d2 = new Double( 400.35 );
       
   559 		Double d3 = new Double(0.0 );
       
   560 		
       
   561 		harness.check(!( d1.shortValue() != 123 ), 
       
   562 			"test_shortbyteValue - 1" );
       
   563 		harness.check(!( d2.shortValue() != 400 ), 
       
   564 			"test_shortbyteValue - 2" );
       
   565 		harness.check(!( d3.shortValue() != 0 ), 
       
   566 			"test_shortbyteValue - 3" );
       
   567 
       
   568 		harness.check(!( d1.byteValue() != 123 ), 
       
   569 			"test_shortbyteValue - 4" );
       
   570 		harness.check(!( d2.byteValue() != (byte) 400 ), 
       
   571 			"test_shortbyteValue - 5" );
       
   572 		harness.check(!( d3.byteValue() != 0 ), 
       
   573 			"test_shortbyteValue - 6" );
       
   574 		
       
   575 	}
       
   576 
       
   577 	public void test_neg() {
       
   578 	    double zero = 0.0;
       
   579 	    String zero1 = String.valueOf(zero);
       
   580 	    if (!zero1.equals("0.0")) {
       
   581 		harness.fail("test_neg - 1");
       
   582 	    }
       
   583 
       
   584 	    zero = -zero;
       
   585 	    String zero2 = String.valueOf(zero);
       
   586 	    if (!zero2.equals("-0.0")) {
       
   587 		harness.fail("test_neg - 2");
       
   588 		System.out.println("Expected -0.0, got: " + zero2);
       
   589 	    }
       
   590 	    
       
   591 	    zero = -zero;
       
   592 	    String zero3 = String.valueOf(zero);
       
   593 	    if (!zero3.equals("0.0")) {
       
   594 		harness.fail("test_neg - 3");
       
   595 	    }
       
   596 	    
       
   597 	    double nonzero = -21.23;
       
   598 	    String nonzero1 = String.valueOf(nonzero);
       
   599 	    if (!nonzero1.equals("-21.23")) {
       
   600 		harness.fail("test_neg - 4");
       
   601 	    }
       
   602 	    
       
   603 	    nonzero = -nonzero;
       
   604 	    String nonzero2 = String.valueOf(nonzero);
       
   605 	    if (!nonzero2.equals("21.23")) {
       
   606 		harness.fail("test_neg - 5");
       
   607 	    }
       
   608 	    
       
   609 	    nonzero = -nonzero;
       
   610 	    String nonzero3 = String.valueOf(nonzero);
       
   611 	    if (!nonzero3.equals("-21.23")) {
       
   612 		harness.fail("test_neg - 6");
       
   613 	    }
       
   614 	}
       
   615 	public void testall()
       
   616 	{
       
   617 		test_Basics();
       
   618 		test_remainder();
       
   619 		test_toString();
       
   620 		test_equals();
       
   621 		test_hashCode();
       
   622 		test_intValue();
       
   623 		test_longValue();
       
   624 		test_DoubleValue();
       
   625 		test_doubleValue();
       
   626 		test_floatValue();
       
   627 		test_shortbyteValue();
       
   628 		test_valueOf();
       
   629 		test_parseDouble();
       
   630 		test_doubleToLongBits();
       
   631 		test_longBitsToDouble();
       
   632 		test_neg();
       
   633 	}
       
   634 
       
   635   public void test (TestHarness the_harness)
       
   636   {
       
   637     harness = the_harness;
       
   638     testall ();
       
   639   }
       
   640 
       
   641 }