diff options
Diffstat (limited to 'jack-tests/tests/com/android/jack/opcodes/sput')
10 files changed, 350 insertions, 0 deletions
diff --git a/jack-tests/tests/com/android/jack/opcodes/sput/TestStubs.java b/jack-tests/tests/com/android/jack/opcodes/sput/TestStubs.java new file mode 100644 index 0000000..551d193 --- /dev/null +++ b/jack-tests/tests/com/android/jack/opcodes/sput/TestStubs.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2008 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.opcodes.sput; + +public class TestStubs { + // used by testE2 + static int TestStubField = 0; + + // used by testE5 + public static final int TestStubFieldFinal = 0; +} diff --git a/jack-tests/tests/com/android/jack/opcodes/sput/Test_sput.java b/jack-tests/tests/com/android/jack/opcodes/sput/Test_sput.java new file mode 100644 index 0000000..37d031c --- /dev/null +++ b/jack-tests/tests/com/android/jack/opcodes/sput/Test_sput.java @@ -0,0 +1,112 @@ +/* + * Copyright (C) 2008 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.opcodes.sput; + +import com.android.jack.DxTestCase; +import com.android.jack.opcodes.sput.jm.T_sput_1; +import com.android.jack.opcodes.sput.jm.T_sput_13; +import com.android.jack.opcodes.sput.jm.T_sput_14; +import com.android.jack.opcodes.sput.jm.T_sput_16; +import com.android.jack.opcodes.sput.jm.T_sput_18; +import com.android.jack.opcodes.sput.jm.T_sput_2; +import com.android.jack.opcodes.sput.jm.T_sput_6; + + +public class Test_sput extends DxTestCase { + + /** + * @title type - int + */ + public void testN1() { + T_sput_1 t = new T_sput_1(); + assertEquals(0, T_sput_1.st_i1); + t.run(); + assertEquals(1000000, T_sput_1.st_i1); + } + + /** + * @title type - double + */ + public void testN2() { + T_sput_2 t = new T_sput_2(); + assertEquals(0d, T_sput_2.st_d1); + t.run(); + assertEquals(1000000d, T_sput_2.st_d1); + } + + /** + * @title modification of protected field from subclass + */ + public void testN4() { + // @uses com.android.jack.opcodes.sput.jm.T_sput_1 + T_sput_14 t = new T_sput_14(); + assertEquals(0, T_sput_14.getProtectedField()); + t.run(); + assertEquals(1000000, T_sput_14.getProtectedField()); + } + + /** + * @title assignment compatible references + */ + public void testN5() { + T_sput_16 t = new T_sput_16(); + assertNull(T_sput_16.o); + t.run(); + assertEquals("", (String) T_sput_16.o); + } + + /** + * @title modification of protected field from subclass + */ + public void testN6() { + T_sput_6 t = new T_sput_6(); + assertEquals(null, T_sput_6.s); + try { + t.run(); + fail ("ClassCastException expected"); + } + catch (ClassCastException e) { + // expected + } + assertEquals(null, T_sput_6.s); + } + + /** + * @title modification of protected field from subclass + */ + public void testN7() { + T_sput_18 t = new T_sput_18(); + assertEquals(0, T_sput_18.v); + t.run(); + assertEquals(3, T_sput_18.v); + } + + /** + * @title initialization of referenced class throws exception + */ + public void testE6() { + // @uses com.android.jack.opcodes.sput.jm.StubInitError + T_sput_13 t = new T_sput_13(); + try { + t.run(); + fail("expected Error"); + } catch (Error e) { + // expected + } + } + +} diff --git a/jack-tests/tests/com/android/jack/opcodes/sput/jm/T_sput_1.java b/jack-tests/tests/com/android/jack/opcodes/sput/jm/T_sput_1.java new file mode 100644 index 0000000..3a7dbb3 --- /dev/null +++ b/jack-tests/tests/com/android/jack/opcodes/sput/jm/T_sput_1.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2008 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.opcodes.sput.jm; + +public class T_sput_1 { + public static int st_i1; + protected static int st_p1; + private static int st_pvt1; + + public void run() { + st_i1 = 1000000; + } + + public static int getPvtField() + { + return st_pvt1; + } +} diff --git a/jack-tests/tests/com/android/jack/opcodes/sput/jm/T_sput_13.java b/jack-tests/tests/com/android/jack/opcodes/sput/jm/T_sput_13.java new file mode 100644 index 0000000..1dfc6df --- /dev/null +++ b/jack-tests/tests/com/android/jack/opcodes/sput/jm/T_sput_13.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2008 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.opcodes.sput.jm; + +public class T_sput_13 { + + public int run() { + return StubInitError.value; + } +} diff --git a/jack-tests/tests/com/android/jack/opcodes/sput/jm/T_sput_14.java b/jack-tests/tests/com/android/jack/opcodes/sput/jm/T_sput_14.java new file mode 100644 index 0000000..63edca5 --- /dev/null +++ b/jack-tests/tests/com/android/jack/opcodes/sput/jm/T_sput_14.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2008 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.opcodes.sput.jm; + +public class T_sput_14 extends T_sput_1{ + + public void run() { + T_sput_1.st_p1 = 1000000; + } + + public static int getProtectedField(){ + return T_sput_1.st_p1; + } + +} diff --git a/jack-tests/tests/com/android/jack/opcodes/sput/jm/T_sput_16.java b/jack-tests/tests/com/android/jack/opcodes/sput/jm/T_sput_16.java new file mode 100644 index 0000000..f34d33e --- /dev/null +++ b/jack-tests/tests/com/android/jack/opcodes/sput/jm/T_sput_16.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2008 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.opcodes.sput.jm; + +public class T_sput_16 { + + public static Object o = null; + + public void run() { + String s = new String(""); + o = s; + } +} diff --git a/jack-tests/tests/com/android/jack/opcodes/sput/jm/T_sput_18.java b/jack-tests/tests/com/android/jack/opcodes/sput/jm/T_sput_18.java new file mode 100644 index 0000000..283c19f --- /dev/null +++ b/jack-tests/tests/com/android/jack/opcodes/sput/jm/T_sput_18.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2008 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.opcodes.sput.jm; + +public class T_sput_18 { + + public static int v; + + public void run() { + v = (int)3.14f; + } +} diff --git a/jack-tests/tests/com/android/jack/opcodes/sput/jm/T_sput_2.java b/jack-tests/tests/com/android/jack/opcodes/sput/jm/T_sput_2.java new file mode 100644 index 0000000..f2cafe5 --- /dev/null +++ b/jack-tests/tests/com/android/jack/opcodes/sput/jm/T_sput_2.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2008 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.opcodes.sput.jm; + +public class T_sput_2 { + + public static double st_d1; + + public void run() { + st_d1 = 1000000d; + } +} diff --git a/jack-tests/tests/com/android/jack/opcodes/sput/jm/T_sput_6.java b/jack-tests/tests/com/android/jack/opcodes/sput/jm/T_sput_6.java new file mode 100644 index 0000000..64f0676 --- /dev/null +++ b/jack-tests/tests/com/android/jack/opcodes/sput/jm/T_sput_6.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2008 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.opcodes.sput.jm; + +public class T_sput_6 { + + public static String s; + + public void run() { + Object o = new Object(); + s = (String)o; + } +} diff --git a/jack-tests/tests/com/android/jack/opcodes/sput/jm/TestStubs.java b/jack-tests/tests/com/android/jack/opcodes/sput/jm/TestStubs.java new file mode 100644 index 0000000..55ce04d --- /dev/null +++ b/jack-tests/tests/com/android/jack/opcodes/sput/jm/TestStubs.java @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2008 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.opcodes.sput.jm; + + +class StubInitError{ + public static int value = 5 / 0; +} |