GNU header update.
[cacao.git] / tests / kaffe / DoubleConst.java
1 /**
2  * Ensure that Double and Float compile time constants are correctly
3  * compiled.
4  *
5  * @author: Edouard G. Parmelan <egp@free.fr> */
6 public class DoubleConst
7 {
8     static void test (String title, float value, int expect)
9     {
10         int got = Float.floatToIntBits (value);
11
12         if (got != expect) {
13             System.out.println (title
14                                 + " expect " + Integer.toString (expect, 16)
15                                 + " got " + Integer.toString (got, 16)
16                                 );
17         }
18     }
19
20     static void test (String title, double value, long expect)
21     {
22         long got = Double.doubleToLongBits (value);
23
24         if (got != expect) {
25             System.out.println (title
26                                 + " expect " + Long.toString (expect, 16)
27                                 + " got " + Long.toString (got, 16)
28                                 );
29         }
30     }
31
32     public static void main (String args[])
33     {
34         System.out.println("Float tests:");
35         test ("POSITIVE_INTINITY", Float.POSITIVE_INFINITY, 0x7f800000);
36         test ("NEGATIVE_INTINITY", Float.NEGATIVE_INFINITY, 0xff800000);
37         test ("NaN", Float.NaN, 0x7fc00000);
38         test ("MIN_VALUE", Float.MIN_VALUE, 0x00000001);
39         test ("MAX_VALUE", Float.MAX_VALUE, 0x7f7fffff);
40
41         System.out.println("Double tests:");
42         test ("POSITIVE_INTINITY", Double.POSITIVE_INFINITY, 0x7ff0000000000000L);
43         test ("NEGATIVE_INTINITY", Double.NEGATIVE_INFINITY, 0xfff0000000000000L);
44         test ("NaN", Double.NaN, 0x7ff8000000000000L);
45         test ("MIN_VALUE", Double.MIN_VALUE, 0x0000000000000001L);
46         test ("MAX_VALUE", Double.MAX_VALUE, 0x7fefffffffffffffL);
47
48     }
49 }
50
51 /* Expected output:
52 Float tests:
53 Double tests:
54 */