Mercurial > hg > graal-compiler
comparison graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/ConstantTest.java @ 18187:9619ba4daf4c
Rename Constant to JavaConstant.
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Thu, 30 Oct 2014 12:21:07 +0100 |
parents | 3ad5e034ac1d |
children | ca81508f2a19 |
comparison
equal
deleted
inserted
replaced
18186:ef357effbda7 | 18187:9619ba4daf4c |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
28 | 28 |
29 public class ConstantTest extends FieldUniverse { | 29 public class ConstantTest extends FieldUniverse { |
30 | 30 |
31 @Test | 31 @Test |
32 public void testNegativeZero() { | 32 public void testNegativeZero() { |
33 Assert.assertTrue("Constant for 0.0f must be different from -0.0f", Constant.FLOAT_0 != Constant.forFloat(-0.0F)); | 33 Assert.assertTrue("Constant for 0.0f must be different from -0.0f", JavaConstant.FLOAT_0 != JavaConstant.forFloat(-0.0F)); |
34 Assert.assertTrue("Constant for 0.0d must be different from -0.0d", Constant.DOUBLE_0 != Constant.forDouble(-0.0d)); | 34 Assert.assertTrue("Constant for 0.0d must be different from -0.0d", JavaConstant.DOUBLE_0 != JavaConstant.forDouble(-0.0d)); |
35 } | 35 } |
36 | 36 |
37 @Test | 37 @Test |
38 public void testNullIsNull() { | 38 public void testNullIsNull() { |
39 Assert.assertTrue(Constant.NULL_OBJECT.isNull()); | 39 Assert.assertTrue(JavaConstant.NULL_OBJECT.isNull()); |
40 } | 40 } |
41 | 41 |
42 @Test | 42 @Test |
43 public void testOne() { | 43 public void testOne() { |
44 for (Kind kind : Kind.values()) { | 44 for (Kind kind : Kind.values()) { |
45 if (kind.isNumericInteger() || kind.isNumericFloat()) { | 45 if (kind.isNumericInteger() || kind.isNumericFloat()) { |
46 Assert.assertTrue(Constant.one(kind).getKind() == kind); | 46 Assert.assertTrue(JavaConstant.one(kind).getKind() == kind); |
47 } | 47 } |
48 } | 48 } |
49 Assert.assertEquals(1, Constant.one(Kind.Int).asInt()); | 49 Assert.assertEquals(1, JavaConstant.one(Kind.Int).asInt()); |
50 Assert.assertEquals(1L, Constant.one(Kind.Long).asLong()); | 50 Assert.assertEquals(1L, JavaConstant.one(Kind.Long).asLong()); |
51 Assert.assertEquals(1, Constant.one(Kind.Byte).asInt()); | 51 Assert.assertEquals(1, JavaConstant.one(Kind.Byte).asInt()); |
52 Assert.assertEquals(1, Constant.one(Kind.Short).asInt()); | 52 Assert.assertEquals(1, JavaConstant.one(Kind.Short).asInt()); |
53 Assert.assertEquals(1, Constant.one(Kind.Char).asInt()); | 53 Assert.assertEquals(1, JavaConstant.one(Kind.Char).asInt()); |
54 Assert.assertTrue(1F == Constant.one(Kind.Float).asFloat()); | 54 Assert.assertTrue(1F == JavaConstant.one(Kind.Float).asFloat()); |
55 Assert.assertTrue(1D == Constant.one(Kind.Double).asDouble()); | 55 Assert.assertTrue(1D == JavaConstant.one(Kind.Double).asDouble()); |
56 } | 56 } |
57 | 57 |
58 @Test(expected = IllegalArgumentException.class) | 58 @Test(expected = IllegalArgumentException.class) |
59 public void testIllegalOne() { | 59 public void testIllegalOne() { |
60 Constant.one(Kind.Illegal); | 60 JavaConstant.one(Kind.Illegal); |
61 } | 61 } |
62 | 62 |
63 @Test(expected = IllegalArgumentException.class) | 63 @Test(expected = IllegalArgumentException.class) |
64 public void testVoidOne() { | 64 public void testVoidOne() { |
65 Constant.one(Kind.Void); | 65 JavaConstant.one(Kind.Void); |
66 } | 66 } |
67 } | 67 } |