|
53 | 53 | * built time for context pre-initialization. |
54 | 54 | */ |
55 | 55 | public class StaticTest { |
56 | | - private static final StaticProperty property; |
| 56 | + private static final StaticProperty propertyB; |
| 57 | + private static final StaticProperty propertyS; |
| 58 | + private static final StaticProperty propertyC; |
| 59 | + private static final StaticProperty propertyI; |
| 60 | + private static final StaticProperty propertyL; |
| 61 | + private static final StaticProperty propertyF; |
| 62 | + private static final StaticProperty propertyD; |
| 63 | + private static final StaticProperty propertyTF; |
| 64 | + private static final StaticProperty propertyO1; |
| 65 | + private static final StaticProperty propertyO2; |
57 | 66 | private static final Object staticObject; |
| 67 | + private static final byte testValueB = 1; |
| 68 | + private static final short testValueS = 2; |
| 69 | + private static final char testValueC = 'a'; |
| 70 | + private static final int testValueI = 3; |
| 71 | + private static final long testValueL = 4; |
| 72 | + private static final float testValueF = 5.0f; |
| 73 | + private static final double testValueD = 6.0; |
| 74 | + private static final boolean testValueTF = true; |
| 75 | + private static final Object testValueO1 = "object1"; |
| 76 | + private static final Object testValueO2 = "object2"; |
58 | 77 |
|
59 | 78 | static { |
60 | 79 | TestEnvironment environment = new TestEnvironment(new TestConfiguration(true, false)); |
61 | 80 | StaticShape.Builder builder = StaticShape.newBuilder(environment.testLanguage); |
62 | | - property = new DefaultStaticProperty("property"); |
63 | | - builder.property(property, int.class, false); |
| 81 | + propertyB = new DefaultStaticProperty("propertyB"); |
| 82 | + propertyS = new DefaultStaticProperty("propertyS"); |
| 83 | + propertyC = new DefaultStaticProperty("propertyC"); |
| 84 | + propertyI = new DefaultStaticProperty("propertyI"); |
| 85 | + propertyL = new DefaultStaticProperty("propertyL"); |
| 86 | + propertyF = new DefaultStaticProperty("propertyF"); |
| 87 | + propertyD = new DefaultStaticProperty("propertyD"); |
| 88 | + propertyTF = new DefaultStaticProperty("propertyTF"); |
| 89 | + propertyO1 = new DefaultStaticProperty("propertyO1"); |
| 90 | + propertyO2 = new DefaultStaticProperty("propertyO2"); |
| 91 | + builder.property(propertyB, byte.class, false); |
| 92 | + builder.property(propertyS, short.class, false); |
| 93 | + builder.property(propertyC, char.class, false); |
| 94 | + builder.property(propertyI, int.class, false); |
| 95 | + builder.property(propertyL, long.class, false); |
| 96 | + builder.property(propertyF, float.class, false); |
| 97 | + builder.property(propertyD, double.class, false); |
| 98 | + builder.property(propertyTF, boolean.class, false); |
| 99 | + builder.property(propertyO1, Object.class, false); |
| 100 | + builder.property(propertyO2, Object.class, false); |
64 | 101 | staticObject = builder.build().getFactory().create(); |
65 | | - property.setInt(staticObject, 42); |
| 102 | + propertyB.setByte(staticObject, testValueB); |
| 103 | + propertyS.setShort(staticObject, testValueS); |
| 104 | + propertyC.setChar(staticObject, testValueC); |
| 105 | + propertyI.setInt(staticObject, testValueI); |
| 106 | + propertyL.setLong(staticObject, testValueL); |
| 107 | + propertyF.setFloat(staticObject, testValueF); |
| 108 | + propertyD.setDouble(staticObject, testValueD); |
| 109 | + propertyTF.setBoolean(staticObject, testValueTF); |
| 110 | + propertyO1.setObject(staticObject, testValueO1); |
| 111 | + propertyO2.setObject(staticObject, testValueO2); |
66 | 112 | } |
67 | 113 |
|
68 | 114 | @Test |
69 | 115 | public void staticallyDeclaredStaticObject() { |
70 | | - Assert.assertEquals(42, property.getInt(staticObject)); |
71 | | - property.setInt(staticObject, 24); |
72 | | - Assert.assertEquals(24, property.getInt(staticObject)); |
| 116 | + Assert.assertEquals(testValueB, propertyB.getByte(staticObject)); |
| 117 | + Assert.assertEquals(testValueS, propertyS.getShort(staticObject)); |
| 118 | + Assert.assertEquals(testValueC, propertyC.getChar(staticObject)); |
| 119 | + Assert.assertEquals(testValueI, propertyI.getInt(staticObject)); |
| 120 | + Assert.assertEquals(testValueL, propertyL.getLong(staticObject)); |
| 121 | + Assert.assertEquals(testValueF, propertyF.getFloat(staticObject), 1e-6f); |
| 122 | + Assert.assertEquals(testValueD, propertyD.getDouble(staticObject), 1e-6); |
| 123 | + Assert.assertEquals(testValueTF, propertyTF.getBoolean(staticObject)); |
| 124 | + Assert.assertEquals(testValueO1, propertyO1.getObject(staticObject)); |
| 125 | + Assert.assertEquals(testValueO2, propertyO2.getObject(staticObject)); |
| 126 | + |
| 127 | + byte newTestValueB = 11; |
| 128 | + propertyB.setByte(staticObject, newTestValueB); |
| 129 | + Assert.assertEquals(newTestValueB, propertyB.getByte(staticObject)); |
| 130 | + |
| 131 | + short newTestValueS = 22; |
| 132 | + propertyS.setShort(staticObject, newTestValueS); |
| 133 | + Assert.assertEquals(newTestValueS, propertyS.getShort(staticObject)); |
| 134 | + |
| 135 | + char newTestValueC = 'b'; |
| 136 | + propertyC.setChar(staticObject, newTestValueC); |
| 137 | + Assert.assertEquals(newTestValueC, propertyC.getChar(staticObject)); |
| 138 | + |
| 139 | + int newTestValueI = 33; |
| 140 | + propertyI.setInt(staticObject, newTestValueI); |
| 141 | + Assert.assertEquals(newTestValueI, propertyI.getInt(staticObject)); |
| 142 | + |
| 143 | + long newTestValueL = 44; |
| 144 | + propertyL.setLong(staticObject, newTestValueL); |
| 145 | + Assert.assertEquals(newTestValueL, propertyL.getLong(staticObject)); |
| 146 | + |
| 147 | + float newTestValueF = 55.0f; |
| 148 | + propertyF.setFloat(staticObject, newTestValueF); |
| 149 | + Assert.assertEquals(newTestValueF, propertyF.getFloat(staticObject), 1e-6f); |
| 150 | + |
| 151 | + double newTestValueD = 66.0; |
| 152 | + propertyD.setDouble(staticObject, newTestValueD); |
| 153 | + Assert.assertEquals(newTestValueD, propertyD.getDouble(staticObject), 1e-6); |
| 154 | + |
| 155 | + propertyTF.setBoolean(staticObject, false); |
| 156 | + Assert.assertFalse(propertyTF.getBoolean(staticObject)); |
| 157 | + |
| 158 | + Object newTestValueO = "object3"; |
| 159 | + propertyO1.setObject(staticObject, newTestValueO); |
| 160 | + Assert.assertEquals(newTestValueO, propertyO1.getObject(staticObject)); |
| 161 | + propertyO2.setObject(staticObject, newTestValueO); |
| 162 | + Assert.assertEquals(newTestValueO, propertyO2.getObject(staticObject)); |
73 | 163 | } |
74 | 164 | } |
0 commit comments