001/*
002 * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation.
008 *
009 * This code is distributed in the hope that it will be useful, but WITHOUT
010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
011 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
012 * version 2 for more details (a copy is included in the LICENSE file that
013 * accompanied this code).
014 *
015 * You should have received a copy of the GNU General Public License version
016 * 2 along with this work; if not, write to the Free Software Foundation,
017 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
018 *
019 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
020 * or visit www.oracle.com if you need additional information or have any
021 * questions.
022 */
023package com.oracle.graal.jtt.reflect;
024
025import org.junit.*;
026
027import com.oracle.graal.jtt.*;
028
029/*
030 */
031public class Field_set01 extends JTTTest {
032
033    public static byte byteField;
034    public static short shortField;
035    public static char charField;
036    public static int intField;
037    public static long longField;
038    public static float floatField;
039    public static double doubleField;
040    public static boolean booleanField;
041
042    public static boolean test(int arg) throws NoSuchFieldException, IllegalAccessException {
043        if (arg == 0) {
044            Field_set01.class.getField("byteField").set(null, Byte.valueOf((byte) 11));
045            return byteField == 11;
046        } else if (arg == 1) {
047            Field_set01.class.getField("shortField").set(null, Short.valueOf((short) 12));
048            return shortField == 12;
049        } else if (arg == 2) {
050            Field_set01.class.getField("charField").set(null, Character.valueOf((char) 13));
051            return charField == 13;
052        } else if (arg == 3) {
053            Field_set01.class.getField("intField").set(null, Integer.valueOf(14));
054            return intField == 14;
055        } else if (arg == 4) {
056            Field_set01.class.getField("longField").set(null, Long.valueOf(15L));
057            return longField == 15;
058        } else if (arg == 5) {
059            Field_set01.class.getField("floatField").set(null, Float.valueOf(16));
060            return floatField == 16;
061        } else if (arg == 6) {
062            Field_set01.class.getField("doubleField").set(null, Double.valueOf(17));
063            return doubleField == 17;
064        } else if (arg == 7) {
065            Field_set01.class.getField("booleanField").set(null, true);
066            return booleanField == true;
067        }
068        return false;
069    }
070
071    @Test
072    public void run0() throws Throwable {
073        runTest("test", 0);
074    }
075
076    @Test
077    public void run1() throws Throwable {
078        runTest("test", 1);
079    }
080
081    @Test
082    public void run2() throws Throwable {
083        runTest("test", 2);
084    }
085
086    @Test
087    public void run3() throws Throwable {
088        runTest("test", 3);
089    }
090
091    @Test
092    public void run4() throws Throwable {
093        runTest("test", 4);
094    }
095
096    @Test
097    public void run5() throws Throwable {
098        runTest("test", 5);
099    }
100
101    @Test
102    public void run6() throws Throwable {
103        runTest("test", 6);
104    }
105
106    @Test
107    public void run7() throws Throwable {
108        runTest("test", 7);
109    }
110
111    @Test
112    public void run8() throws Throwable {
113        runTest("test", 8);
114    }
115
116}