jdk/test/com/sun/jdi/ArgumentValuesTest.java
author jjg
Thu, 22 May 2008 15:51:41 -0700
changeset 655 1ebc7ce89018
parent 2 90ce3da70b43
child 24973 8c4bc3fa4c4e
permissions -rw-r--r--
6705945: com.sun.tools.javac.zip files do not have valid copyright Reviewed-by: mcimadamore
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/** hard coded linenumbers in other tests - DO NOT CHANGE
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 *  @test/nodynamiccopyright/
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 *  @bug 4490824
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *  @summary JDI: provide arguments when no debug attributes present
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 *  @author jjh
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *  @run build TestScaffold VMConnection TargetListener TargetAdapter
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 *  @run compile ArgumentValuesTest.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *  @run main ArgumentValuesTest
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
import com.sun.jdi.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
import com.sun.jdi.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
import com.sun.jdi.request.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 /********** target program **********/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
class ArgumentValuesTarg {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
    static char s_char1 = 'a';
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
    static byte s_byte1 = (byte) 146;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
    static short s_short1 = (short) 28123;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
    static int s_int1 = 3101246;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
    static long s_long1 = 0x0123456789ABCDEFL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
    static float s_float1 = 2.3145f;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
    static double s_double1 = 1.469d;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
    static int s_iarray1[] = {1, 2, 3};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
    static int s_marray1[][] = {{1, 2, 3}, {3, 4, 5}, null, {6, 7}};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
    static String s_sarray1[] = {"abc", null, "def", "ghi"};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
    static String s_string1 = "abcdef";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
    static String s_string2 = "xy";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
    static String s_string3 = "wz";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
    static List<Integer> intList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
    public static void noArgs() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
        int index = 0;     // line 38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    public static void allArgs(char p_char, byte p_byte, short p_short,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
                               int p_int, long p_long, float p_float,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
                               double p_double, int p_iarray[], int p_marray[][],
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
                               String p_sarray1[], String p_string) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
        int index = 0;      // line 45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    public static void varArgs(String ... p1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
        int index = 0;     // line 49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    public static void genericArgs(List<Integer> p1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        int index = 0;     // line 53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    public void instanceMethod(char p_char, byte p_byte) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        int index = 0;     // line 57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    public static void main(String[] args) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        System.out.println("Howdy!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        allArgs(
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
                s_char1,   s_byte1,   s_short1,  s_int1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
                s_long1,   s_float1,  s_double1, s_iarray1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
                s_marray1, s_sarray1, s_string1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        noArgs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        varArgs(s_string1, s_string2, s_string3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        ArgumentValuesTarg avt = new ArgumentValuesTarg();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        intList = new ArrayList<Integer>(10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        intList.add(10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        intList.add(20);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        genericArgs(intList);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        avt.instanceMethod(s_char1, s_byte1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        System.out.println("Goodbye from ArgumentValuesTarg!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 /********** test program **********/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
public class ArgumentValuesTest extends TestScaffold {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    // Must be in same order as args to allArgs(....)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    String fieldNames[] = {"s_char1",   "s_byte1",   "s_short1",  "s_int1",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
                           "s_long1",   "s_float1",  "s_double1", "s_iarray1",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
                           "s_marray1", "s_sarray1", "s_string1"};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    String fieldNamesVarArgs[] = {"s_string1", "s_string2", "s_string3"};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    String fieldNamesInstance[] = {"s_char1",   "s_byte1"};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    ReferenceType targetClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    ThreadReference mainThread;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    ArgumentValuesTest (String args[]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        super(args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    public static void main(String[] args)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        throws Exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        new ArgumentValuesTest (args).startTests();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    /********** test core **********/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    protected void runTests()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        throws Exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
         * Get to the top of main() to determine targetClass and mainThread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        BreakpointEvent bpe = startToMain("ArgumentValuesTarg");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        targetClass = bpe.location().declaringType();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        mainThread = bpe.thread();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        EventRequestManager erm = vm().eventRequestManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
            System.out.println("----- Testing each type of arg");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
            bpe = resumeTo("ArgumentValuesTarg", 45);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            StackFrame frame = bpe.thread().frame(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
            Method mmm = frame.location().method();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            System.out.println("Arg types are: " + mmm.argumentTypeNames());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
            List<Value> argVals = frame.getArgumentValues();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            if (argVals.size() != fieldNames.length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                failure("failure: Varargs: expected length " + fieldNames.length +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                        " args, got: " + argVals);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            for (int ii = 0; ii < argVals.size(); ii++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                Value gotVal = argVals.get(ii);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                Field theField = targetClass.fieldByName(fieldNames[ii]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                Value expectedVal = targetClass.getValue(theField);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                System.out.println(fieldNames[ii] + ": gotVal = " + gotVal +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
                                   ", expected = " + expectedVal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                //System.out.println(gotVal.getClass() + ", " + expectedVal.getClass());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
                if (!gotVal.equals(expectedVal)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
                    failure("     failure: gotVal != expected");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        // a method with no params
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
            System.out.println("----- Testing no args");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            bpe = resumeTo("ArgumentValuesTarg", 38);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
            StackFrame frame = bpe.thread().frame(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
            Method mmm = frame.location().method();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
            System.out.println("Arg types are: " + mmm.argumentTypeNames());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
            List<Value> argVals = frame.getArgumentValues();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
            if (argVals.size() == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                System.out.println("Empty arg list ok");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                failure("failure: Expected empty val list, got: " + argVals);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        // var args.  3 Strings are passed in and they appear
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        // as a String[3] in the method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            System.out.println("----- Testing var args");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
            bpe = resumeTo("ArgumentValuesTarg", 49);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
            StackFrame frame = bpe.thread().frame(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
            Method mmm = frame.location().method();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
            System.out.println("Arg types are: " + mmm.argumentTypeNames());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
            List<Value> argVals = frame.getArgumentValues();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
            if (argVals.size() != 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                failure("failure: Varargs: expected one arg, got: " + argVals);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
            argVals = ((ArrayReference)argVals.get(0)).getValues();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
            if (argVals.size() != fieldNamesVarArgs.length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
                failure("failure: Varargs: expected length " + fieldNamesVarArgs.length +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
                        " array elements, got: " + argVals);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            for (int ii = 0; ii < argVals.size(); ii++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                Value gotVal = argVals.get(ii);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                Field theField = targetClass.fieldByName(fieldNamesVarArgs[ii]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                Value expectedVal = targetClass.getValue(theField);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                System.out.println(fieldNamesVarArgs[ii] + ": gotVal = " + gotVal +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                                   ", expected = " + expectedVal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                //System.out.println(gotVal.getClass() + ", " + expectedVal.getClass());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                if (!gotVal.equals(expectedVal)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                    failure("     failure: gotVal != expected");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        // a method with with one generic param
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            System.out.println("----- Testing generic args");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            bpe = resumeTo("ArgumentValuesTarg", 53);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            StackFrame frame = bpe.thread().frame(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            Method mmm = frame.location().method();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
            System.out.println("Arg types are: " + mmm.argumentTypeNames());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
            List<Value> argVals = frame.getArgumentValues();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
            if (argVals.size() != 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                failure("failure: Expected one arg, got: " + argVals);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                Value gotVal = argVals.get(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                Field theField = targetClass.fieldByName("intList");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
                Value expectedVal = targetClass.getValue(theField);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                System.out.println("intList " + ": gotVal = " + gotVal +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
                                   ", expected = " + expectedVal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                if (!gotVal.equals(expectedVal)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                    failure("failure: gotVal != expected");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        // test instance method call
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
            System.out.println("----- Testing instance method call");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            bpe = resumeTo("ArgumentValuesTarg", 57);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            StackFrame frame = bpe.thread().frame(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
            Method mmm = frame.location().method();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
            System.out.println("Arg types are: " + mmm.argumentTypeNames());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
            List<Value> argVals = frame.getArgumentValues();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
            if (argVals.size() != fieldNamesInstance.length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
                failure("failure: Varargs: expected length " + fieldNamesInstance.length +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
                        " args, got: " + argVals);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            for (int ii = 0; ii < argVals.size(); ii++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
                Value gotVal = argVals.get(ii);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
                Field theField = targetClass.fieldByName(fieldNamesInstance[ii]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
                Value expectedVal = targetClass.getValue(theField);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
                System.out.println(fieldNamesInstance[ii] + ": gotVal = " + gotVal +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
                                   ", expected = " + expectedVal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
                //System.out.println(gotVal.getClass() + ", " + expectedVal.getClass());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
                if (!gotVal.equals(expectedVal)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
                    failure("     failure: gotVal != expected");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
         * resume the target listening for events
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        listenUntilVMDisconnect();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
         * deal with results of test if anything has called failure("foo")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
         * testFailed will be true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        if (!testFailed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
            println("ArgumentValuesTest: passed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
            throw new Exception("ArgumentValuesTest: failed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
}