diff options
Diffstat (limited to 'jack-tests/tests/com/android/jack/constant')
17 files changed, 821 insertions, 0 deletions
diff --git a/jack-tests/tests/com/android/jack/constant/clazz/dx/Tests.java b/jack-tests/tests/com/android/jack/constant/clazz/dx/Tests.java new file mode 100644 index 0000000..583b5de --- /dev/null +++ b/jack-tests/tests/com/android/jack/constant/clazz/dx/Tests.java @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * 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.android.jack.constant.clazz.dx; + +import com.android.jack.constant.clazz.jack.Data; + +import junit.framework.Assert; + +import org.junit.Test; + +/** + * Tests class. + */ +public class Tests { + + @Test + public void getPrimitiveVoidClass() { + Assert.assertTrue(Data.getPrimitiveVoidClass().getName().equals("void")); + } + + @Test + public void getPrimitiveByteClass() { + Assert.assertTrue(Data.getPrimitiveByteClass().getName().equals("byte")); + } + + @Test + public void getPrimitiveBooleanClass() { + Assert.assertTrue(Data.getPrimitiveBooleanClass().getName().equals("boolean")); + } + + @Test + public void getPrimitiveCharClass() { + Assert.assertTrue(Data.getPrimitiveCharClass().getName().equals("char")); + } + + @Test + public void getPrimitiveShortClass() { + Assert.assertTrue(Data.getPrimitiveShortClass().getName().equals("short")); + } + + @Test + public void getPrimitiveIntClass() { + Assert.assertTrue(Data.getPrimitiveIntClass().getName().equals("int")); + } + + @Test + public void getPrimitiveFloatClass() { + Assert.assertTrue(Data.getPrimitiveFloatClass().getName().equals("float")); + } + + @Test + public void getPrimitiveLongClass() { + Assert.assertTrue(Data.getPrimitiveLongClass().getName().equals("long")); + } + + @Test + public void getPrimitiveDoubleClass() { + Assert.assertTrue(Data.getPrimitiveDoubleClass().getName().equals("double")); + } + + @Test + public void getObjectVoidClass() { + System.out.println(Data.getObjectVoidClass().getName()); + Assert.assertTrue(Data.getObjectVoidClass().getName().equals("java.lang.Void")); + } +} diff --git a/jack-tests/tests/com/android/jack/constant/clazz/jack/Data.java b/jack-tests/tests/com/android/jack/constant/clazz/jack/Data.java new file mode 100644 index 0000000..a108f22 --- /dev/null +++ b/jack-tests/tests/com/android/jack/constant/clazz/jack/Data.java @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * 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.android.jack.constant.clazz.jack; + +public class Data { + + public static Class<?> getPrimitiveVoidClass() { + return void.class; + } + + public static Class<?> getPrimitiveIntClass() { + return int.class; + } + + public static Class<?> getPrimitiveBooleanClass() { + return boolean.class; + } + + public static Class<?> getPrimitiveByteClass() { + return byte.class; + } + + public static Class<?> getPrimitiveCharClass() { + return char.class; + } + + public static Class<?> getPrimitiveShortClass() { + return short.class; + } + + public static Class<?> getPrimitiveFloatClass() { + return float.class; + } + + public static Class<?> getPrimitiveDoubleClass() { + return double.class; + } + + public static Class<?> getPrimitiveLongClass() { + return long.class; + } + + public static Class<?> getObjectVoidClass() { + return Void.class; + } +} diff --git a/jack-tests/tests/com/android/jack/constant/test001/dx/Tests.java b/jack-tests/tests/com/android/jack/constant/test001/dx/Tests.java new file mode 100644 index 0000000..6c82463 --- /dev/null +++ b/jack-tests/tests/com/android/jack/constant/test001/dx/Tests.java @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * 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.android.jack.constant.test001.dx; + +import com.android.jack.constant.test001.jack.Constant; + +import org.junit.Assert; +import org.junit.Test; + +public class Tests { + @Test + public void constantBooleanTrue() { + Assert.assertTrue(Constant.getBooleanTrue()); + } + + @Test + public void constantBooleanFalse() { + Assert.assertFalse(Constant.getBooleanFalse()); + } + + @Test + public void constantChar() { + Assert.assertEquals('d', Constant.getChar()); + } + + @Test + public void constantDouble() { + Assert.assertEquals(12.3, Constant.getDouble(), 0); + } + + @Test + public void constantFloat() { + Assert.assertEquals(23.4f, Constant.getFloat(), 0); + } + + @Test + public void constantInt() { + Assert.assertEquals(1337, Constant.getInt()); + } + + @Test + public void constantLong() { + Assert.assertEquals(345l, Constant.getLong()); + } + + @Test + public void constantByte() { + Assert.assertEquals(-1, Constant.getByte()); + } + + @Test + public void constantShort() { + Assert.assertEquals(456, Constant.getShort()); + } + + @Test + public void constantString() { + Assert.assertEquals("abc", Constant.getString()); + } + + @Test + public void constantNull() { + Assert.assertNull(Constant.getNull()); + } + + public void constantObjectClass() { + Class<?> cl = Constant.getObjectClass(); + Assert.assertNotNull(cl); + Assert.assertEquals("java.lang.Object", cl.getName()); + } + + @Test + public void constantClass() { + Class<?> cl = Constant.getConstantClass(); + Assert.assertNotNull(cl); + Assert.assertEquals("com.android.jack.constant.test001.jack.Constant", cl.getName()); + } + + @Test + public void constantIntClass() { + Class<?> cl = Constant.getIntClass(); + Assert.assertNotNull(cl); + Assert.assertEquals("int", cl.getName()); + } + + @Test + public void constantArrayClass() { + Class<?> cl = Constant.getArrayClass(); + Assert.assertNotNull(cl); + Assert.assertEquals("[I", cl.getName()); + } +} diff --git a/jack-tests/tests/com/android/jack/constant/test001/jack/Constant.java b/jack-tests/tests/com/android/jack/constant/test001/jack/Constant.java new file mode 100644 index 0000000..1d3cedb --- /dev/null +++ b/jack-tests/tests/com/android/jack/constant/test001/jack/Constant.java @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * 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.android.jack.constant.test001.jack; + +public class Constant { + + public static boolean getBooleanTrue() { + return true; + } + + public static boolean getBooleanFalse() { + return false; + } + + public static char getChar() { + return 'd'; + } + + public static double getDouble() { + return 12.3; + } + + public static float getFloat() { + return 23.4f; + } + + public static int getInt() { + return 1337; + } + + public static long getLong() { + return 345l; + } + + public static byte getByte() { + return -1; + } + + public static short getShort() { + return 456; + } + + public static String getString() { + return "abc"; + } + + public static Object getNull() { + return null; + } + + public static Class getObjectClass() { + return Object.class; + } + + public static Class getConstantClass() { + return Constant.class; + } + + public static Class getIntClass() { + return int.class; + } + + public static Class getArrayClass() { + return int[].class; + } +} diff --git a/jack-tests/tests/com/android/jack/constant/test002/dx/Tests.java b/jack-tests/tests/com/android/jack/constant/test002/dx/Tests.java new file mode 100644 index 0000000..d619c3b --- /dev/null +++ b/jack-tests/tests/com/android/jack/constant/test002/dx/Tests.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * 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.android.jack.constant.test002.dx; + +import com.android.jack.constant.test002.jack.ConstantReuse; + +import org.junit.Test; + +public class Tests { + @Test + public void test() { + ConstantReuse cr = new ConstantReuse(); + cr.booleanConstantReuse(); + cr.byteConstantReuse(); + cr.charConstantReuse(); + cr.doubleConstantReuse(); + cr.floatConstantReuse(); + cr.intConstantReuse(); + cr.longConstantReuse(); + cr.shortConstantReuse(); + cr.nullConstantReuse(); + } +} diff --git a/jack-tests/tests/com/android/jack/constant/test002/jack/ConstantReuse.java b/jack-tests/tests/com/android/jack/constant/test002/jack/ConstantReuse.java new file mode 100644 index 0000000..a9f8b5b --- /dev/null +++ b/jack-tests/tests/com/android/jack/constant/test002/jack/ConstantReuse.java @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * 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.android.jack.constant.test002.jack; + +public class ConstantReuse { + + public void intConstantReuse() { + int a = 0; + int b = 0; + int c = 1; + int d = 1; + } + + public void byteConstantReuse() { + byte a = (byte) 0; + byte b = (byte) 0; + byte c = (byte) 1; + byte d = (byte) 1; + } + + public void shortConstantReuse() { + short a = (short) 0; + short b = (short) 0; + short c = (short) 1; + short d = (short) 1; + } + + public void charConstantReuse() { + char a = (char) 0; + char b = (char) 0; + char c = (char) 1; + char d = (char) 1; + } + + public void floatConstantReuse() { + float a = (float) 0.0; + float b = (float) 0.0; + float c = (float) 1.2; + float d = (float) 1.2; + } + + public void longConstantReuse() { + long a = 0L; + long b = 0L; + long c = 1L; + long d = 1L; + } + + public void doubleConstantReuse() { + double a = 0.0; + double b = 0.0; + double c = 1.2; + double d = 1.2; + } + + public void booleanConstantReuse() { + boolean a = true; + boolean b = true; + boolean c = false; + boolean d = false; + } + + public void nullConstantReuse() { + Object a = null; + Object b = null; + } +} diff --git a/jack-tests/tests/com/android/jack/constant/test003/dx/Tests.java b/jack-tests/tests/com/android/jack/constant/test003/dx/Tests.java new file mode 100644 index 0000000..0695781 --- /dev/null +++ b/jack-tests/tests/com/android/jack/constant/test003/dx/Tests.java @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * 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.android.jack.constant.test003.dx; + +import com.android.jack.constant.test003.jack.Constant003; + +import org.junit.Assert; +import org.junit.Test; + +public class Tests { + + @Test + public void testNPE() { + try { + Constant003.getZERO(); + Assert.fail(); + } catch (NullPointerException e) { + // expected + } + } + + @Test + public void testSwitch() { + Assert.assertEquals(0, new Constant003().get(0)); + Assert.assertEquals(1, new Constant003().get(1)); + Assert.assertEquals(2, new Constant003().get(2)); + Assert.assertEquals(2, new Constant003().get(-1)); + } + +} diff --git a/jack-tests/tests/com/android/jack/constant/test003/jack/Constant003.java b/jack-tests/tests/com/android/jack/constant/test003/jack/Constant003.java new file mode 100644 index 0000000..178d546 --- /dev/null +++ b/jack-tests/tests/com/android/jack/constant/test003/jack/Constant003.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * 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.android.jack.constant.test003.jack; + +public class Constant003 { + + private final int ZERO = 0; + private static final int ONE = 1; + + public static int getZERO() { + return ((Constant003) null).ZERO; + } + + public int get(int value) { + switch (value) { + case ZERO: + return 0; + case ONE: + return 1; + default: + return 2; + } + } +} diff --git a/jack-tests/tests/com/android/jack/constant/test004/dx/Tests.java b/jack-tests/tests/com/android/jack/constant/test004/dx/Tests.java new file mode 100644 index 0000000..35779ca --- /dev/null +++ b/jack-tests/tests/com/android/jack/constant/test004/dx/Tests.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * 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.android.jack.constant.test004.dx; + +import com.android.jack.constant.test004.jack.Constant004; + +import org.junit.Assert; +import org.junit.Test; + +public class Tests { + + @Test + public void testSccpBehavior() { + Assert.assertEquals(3, new Constant004().get()); + } + +} diff --git a/jack-tests/tests/com/android/jack/constant/test004/jack/Constant004.java b/jack-tests/tests/com/android/jack/constant/test004/jack/Constant004.java new file mode 100644 index 0000000..5537ccc --- /dev/null +++ b/jack-tests/tests/com/android/jack/constant/test004/jack/Constant004.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * 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.android.jack.constant.test004.jack; + +public class Constant004 { + + public int get() { + boolean a = true; + if (a) { + return 3; + } else { + return 2; + } + } +} diff --git a/jack-tests/tests/com/android/jack/constant/test005/dx/Tests.java b/jack-tests/tests/com/android/jack/constant/test005/dx/Tests.java new file mode 100644 index 0000000..c6fa848 --- /dev/null +++ b/jack-tests/tests/com/android/jack/constant/test005/dx/Tests.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * 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.android.jack.constant.test005.dx; + +import com.android.jack.constant.test005.jack.Constant005; + +import org.junit.Assert; +import org.junit.Test; + +public class Tests { + + @Test + public void testWithConstant() { + Assert.assertEquals(56, new Constant005().test()); + } + +} diff --git a/jack-tests/tests/com/android/jack/constant/test005/jack/Constant005.java b/jack-tests/tests/com/android/jack/constant/test005/jack/Constant005.java new file mode 100644 index 0000000..5b5982b --- /dev/null +++ b/jack-tests/tests/com/android/jack/constant/test005/jack/Constant005.java @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * 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.android.jack.constant.test005.jack; + +/** + * Test checking that there is only seven constant defined into the generated code. + */ +public class Constant005 { + + public int sum(int a, int b) { + return a + b; + } + + public int test() { + int a = 1; + int b = 2; + int c = 3; + int d = 4; + int e = 5; + int f = 6; + int g = 7; + int sum1 = sum (a,a); + int sum2 = sum (b,b); + int sum3 = sum (c,c); + int sum4 = sum (d,d); + int sum5 = sum (e,e); + int sum6 = sum (f,f); + int sum7 = sum (g,g); + return sum1 + sum2 + sum3 + sum4 + sum5 + sum6 + sum7; + } +}
\ No newline at end of file diff --git a/jack-tests/tests/com/android/jack/constant/test006/dx/Tests.java b/jack-tests/tests/com/android/jack/constant/test006/dx/Tests.java new file mode 100644 index 0000000..a79a85f --- /dev/null +++ b/jack-tests/tests/com/android/jack/constant/test006/dx/Tests.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * 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.android.jack.constant.test006.dx; + +import com.android.jack.constant.test006.jack.Constant006; + +import org.junit.Assert; +import org.junit.Test; + +public class Tests { + + @Test + public void testWithConstant() { + Assert.assertEquals(11, new Constant006().test(true)); + } + +} diff --git a/jack-tests/tests/com/android/jack/constant/test006/jack/Constant006.java b/jack-tests/tests/com/android/jack/constant/test006/jack/Constant006.java new file mode 100644 index 0000000..ff06cd9 --- /dev/null +++ b/jack-tests/tests/com/android/jack/constant/test006/jack/Constant006.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * 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.android.jack.constant.test006.jack; + +/** + * Test checking that the constant {@code a} is not propagate as a float. + */ +public class Constant006 { + + public int test(boolean b) { + int a = 10; + float c = a; + return a + 1; + } +}
\ No newline at end of file diff --git a/jack-tests/tests/com/android/jack/constant/test007/dx/Tests.java b/jack-tests/tests/com/android/jack/constant/test007/dx/Tests.java new file mode 100644 index 0000000..4a5608c --- /dev/null +++ b/jack-tests/tests/com/android/jack/constant/test007/dx/Tests.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * 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.android.jack.constant.test007.dx; + + +import com.android.jack.constant.test007.jack.Constant007; + +import org.junit.Assert; +import org.junit.Test; + +public class Tests { + + @Test + public void testConstant() { + Assert.assertEquals(1000, new Constant007().get(500), 0); + Assert.assertEquals(500, new Constant007().get(1000), 0); + } + +} diff --git a/jack-tests/tests/com/android/jack/constant/test007/jack/Constant007.java b/jack-tests/tests/com/android/jack/constant/test007/jack/Constant007.java new file mode 100644 index 0000000..4d59ae2 --- /dev/null +++ b/jack-tests/tests/com/android/jack/constant/test007/jack/Constant007.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * 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.android.jack.constant.test007.jack; + +/** + * Test checking that the constant {@code time} is not propagated as a float. + */ +public class Constant007 { + + public float get(int value) { + int time = 500; + if (value == time) { + time = 1000; + } + return time; + } +} diff --git a/jack-tests/tests/com/android/jack/constant/test008/jack/Constant008.java b/jack-tests/tests/com/android/jack/constant/test008/jack/Constant008.java new file mode 100644 index 0000000..5753b8c --- /dev/null +++ b/jack-tests/tests/com/android/jack/constant/test008/jack/Constant008.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * 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.android.jack.constant.test008.jack; + +/** + * Test checking that type of {@code time} is not changed to long due to constant optimization. + */ +public class Constant008 { + + private int field = 500; + + public long get() { + int time = field; + if (time < 0) { + time = 1; + } else { + time = 2; + } + return time; + } +} |