jdk/test/com/sun/jdi/ArrayRangeTest.java
author xdono
Thu, 30 Apr 2009 15:04:39 -0700
changeset 2691 bad7bbf42755
parent 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
Added tag jdk7-b57 for changeset 93833fce07e3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2001 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 *  @test
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 *  @bug 4439631
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 *  @bug 4448721
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 *  @bug 4448603
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 *  @summary Test access to ranges within ArrayReferences
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 *  @author Robert Field
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 *  @run build TestScaffold VMConnection TargetListener TargetAdapter
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 *  @run compile -g ArrayRangeTest.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 *  @run main ArrayRangeTest
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import com.sun.jdi.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import com.sun.jdi.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import com.sun.jdi.request.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    /********** target program **********/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
class ArrayRangeTarg {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    static int[] emptyArray = {};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    static int[] fullArray = {0, 100, 200, 300, 400};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    public static void main(String[] args) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
        System.out.println("Goodbye from ArrayRangeTarg!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    /********** test program **********/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
public class ArrayRangeTest extends TestScaffold {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    ReferenceType targetClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    class Sample {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        Sample(String name, ArrayReference arrRef, int[] expected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
            this.name = name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
            this.arrRef = arrRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
            this.expected = expected;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        String name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        ArrayReference arrRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        int[] expected;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    ArrayRangeTest (String args[]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        super(args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    public static void main(String[] args)      throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        new ArrayRangeTest(args).startTests();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    /********** test assist **********/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    String arr(int a[]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        StringBuffer buf = new StringBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        buf.append('[');
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        if (a.length > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
            buf.append(a[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
            for (int i = 1; i < a.length; ++i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
                buf.append(',');
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
                buf.append(a[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        buf.append(']');
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        return buf.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    void getValueGood(Sample samp, int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
            Value val = samp.arrRef.getValue(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
            int ival = ((IntegerValue)val).value();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
            if (ival != samp.expected[index]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
                failure("FAIL - " + samp.name +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
                        ".getValue(" + index + ") - wrong value=" + ival);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
                println("pass - " + samp.name +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
                        ".getValue(" + index + ") - value=" + ival);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        } catch (Throwable exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
            failure("FAIL - " + samp.name +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
                    ".getValue(" + index + ") - unexpected: " + exc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    void getValueBad(Sample samp, int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
            Value val = samp.arrRef.getValue(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
            failure("FAIL - " + samp.name +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
                    ".getValue(" + index + ") - no expected exception");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        } catch (IndexOutOfBoundsException exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
            println("pass - " + samp.name +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
                    ".getValue(" + index + ") - got expected: " + exc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        } catch (Throwable exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
            failure("FAIL - " + samp.name +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
                    ".getValue(" + index + ") - unexpected: " + exc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    void getValuesGood(Sample samp) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        String desc = samp.name + ".getValues()";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
            List vals = samp.arrRef.getValues();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            if (vals.size() != samp.expected.length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                failure("FAIL - " + desc +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                        " - wrong size=" + vals.size() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                        " , expected: " + samp.expected.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
            for (int index = 0; index < vals.size(); ++index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                int ival = ((IntegerValue)vals.get(index)).value();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                if (ival != samp.expected[index]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                    failure("FAIL - " + desc +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                            " - wrong value=" + ival);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
                    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            println("pass - " + samp.name + ".getValues())");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        } catch (Throwable exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
            failure("FAIL - " + desc  +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
                    " - unexpected: " + exc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    void getValuesGood(Sample samp, int index, int length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
            List vals = samp.arrRef.getValues(index, length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
            if (vals.size() !=
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
                 ((length==-1)? (samp.expected.length - index) : length)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
                failure("FAIL - " + samp.name + ".getValues(" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
                        index + ", " + length + ") - wrong size=" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                        vals.size());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
            for (int i = 0; i < vals.size(); ++i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
                int ival = ((IntegerValue)vals.get(i)).value();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                if (ival != samp.expected[index + i]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
                    failure("FAIL - " + samp.name + ".getValues(" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
                            index + ", " + length + ") - wrong value=" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
                            ival);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            println("pass - " + samp.name + ".getValues(" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                    index + ", " + length + "))");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        } catch (Throwable exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
            failure("FAIL - " + samp.name + ".getValues(" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
                    index + ", " + length + ") - unexpected: " + exc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    void getValuesBad(Sample samp, int index, int length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
            List vals = samp.arrRef.getValues(index, length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
            failure("FAIL - " + samp.name + ".getValues(" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                        index + ", " + length + ") - no expected exception");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        } catch (IndexOutOfBoundsException exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
            println("pass - " + samp.name + ".getValue(" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
                    index + ", " + length + ") - got expected: " + exc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        } catch (Throwable exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            failure("FAIL - " + samp.name + ".getValues(" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                    index + ", " + length + ") - unexpected: " + exc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    void setValueGood(Sample samp, int index, int ival) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            Value val = vm().mirrorOf(ival);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
            samp.arrRef.setValue(index, val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
            println("pass - " + samp.name +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                    ".setValue(" + index + ", ..)");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        } catch (Throwable exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            failure("FAIL - " + samp.name +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                    ".setValue(" + index + ",...) - unexpected: " + exc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    void setValueBad(Sample samp, int index, int ival) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            Value val = vm().mirrorOf(ival);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            samp.arrRef.setValue(index, val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            failure("FAIL - " + samp.name +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                    ".setValue(" + index + ", ..) - no expected exception");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        } catch (IndexOutOfBoundsException exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
            println("pass - " + samp.name +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                    ".setValue(" + index + ",...) - got expected: " + exc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        } catch (Throwable exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
            failure("FAIL - " + samp.name +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                    ".setValue(" + index + ",...) - unexpected: " + exc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    void setValuesGood(Sample samp, int[] valArray) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        String desc = samp.name + ".setValues(" + arr(valArray) + ")";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
            List values = new ArrayList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
            for (int i = 0; i < valArray.length; ++i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                Value val = vm().mirrorOf(valArray[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                values.add(val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            samp.arrRef.setValues(values);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
            println("pass - " + desc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        } catch (Throwable exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            failure("FAIL - " + desc + " - unexpected: " + exc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    void setValuesGood(Sample samp, int index, int[] valArray,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                       int srcInx, int length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        String desc = samp.name + ".setValues(" + index + ", " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
            arr(valArray) + ", " + srcInx + ", " + length + ")";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
            List values = new ArrayList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
            for (int i = 0; i < valArray.length; ++i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
                Value val = vm().mirrorOf(valArray[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
                values.add(val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            samp.arrRef.setValues(index, values, srcInx, length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
            println("pass - " + desc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        } catch (Throwable exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
            failure("FAIL - " + desc + " - unexpected: " + exc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    void setValuesBad(Sample samp, int index, int[] valArray,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
                       int srcInx, int length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        String desc = samp.name + ".setValues(" + index + ", " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
            arr(valArray) + ", " + srcInx + ", " + length + ")";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
            List values = new ArrayList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            for (int i = 0; i < valArray.length; ++i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
                Value val = vm().mirrorOf(valArray[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
                values.add(val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
            samp.arrRef.setValues(index, values, srcInx, length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
            failure("FAIL - " + desc + " - no expected exception");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        } catch (IndexOutOfBoundsException exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
            println("pass - " + desc + " - got expected: " + exc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        } catch (Throwable exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
            failure("FAIL - " + desc + " - unexpected: " + exc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
    void check(Sample samp, int[] expectArray) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        String desc = samp.name + " - check - " + arr(expectArray);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
            List vals = samp.arrRef.getValues();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
            if (vals.size() != expectArray.length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
                failure("FAIL - " + desc +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
                        " - wrong size=" + vals.size() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
                        " , expected: " + expectArray.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
            for (int index = 0; index < vals.size(); ++index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
                int ival = ((IntegerValue)vals.get(index)).value();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
                if (ival != expectArray[index]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
                    failure("FAIL - " + desc +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
                            " - wrong value=" + ival);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
                    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
            println("pass - " + desc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        } catch (Throwable exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
            failure("FAIL - " + desc  +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
                    " - unexpected: " + exc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    /********** test core **********/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    protected void runTests() throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
         * Get to the top of main() to determine targetClass
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        BreakpointEvent bpe = startToMain("ArrayRangeTarg");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        targetClass = bpe.location().declaringType();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        Field fullField = targetClass.fieldByName("fullArray");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        Field emptyField = targetClass.fieldByName("emptyArray");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        ArrayReference emptyAR = (ArrayReference)targetClass.getValue(emptyField);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        ArrayReference fullAR = (ArrayReference)targetClass.getValue(fullField);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        Sample full = new Sample("full", fullAR, ArrayRangeTarg.fullArray);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        Sample empty = new Sample("empty", emptyAR, ArrayRangeTarg.emptyArray);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        getValueGood(full, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        getValueGood(full, 4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
        // index < 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
        getValueBad(full, -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
        getValueBad(full, -2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        getValueBad(empty, -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
        getValueBad(empty, -2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        // index >= length
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
        getValueBad(full, 5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        getValueBad(empty, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
        getValueBad(empty, 5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        getValuesGood(full);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        getValuesGood(empty);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        getValuesGood(full, 0, 5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
        getValuesGood(full, 0, 4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
        getValuesGood(full, 1, 4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
        getValuesGood(full, 5, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        getValuesGood(full, 0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
        getValuesGood(full, 0, -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        getValuesGood(full, 1, -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
        getValuesGood(full, 5, -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        getValuesGood(empty, 0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        getValuesGood(empty, 0, -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        // index < 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        getValuesBad(full, -1, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        getValuesBad(full, -1, 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        getValuesBad(full, -1, -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        getValuesBad(empty, -1, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
        getValuesBad(full, -2, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        getValuesBad(full, -2, 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        getValuesBad(full, -2, -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        getValuesBad(empty, -2, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        // index > length()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        getValuesBad(full, 6, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
        getValuesBad(full, 6, -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        getValuesBad(empty, 1, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
        getValuesBad(empty, 1, -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
        // length < 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
        getValuesBad(full, 0, -2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
        getValuesBad(empty, 0, -2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
        // index + length > length()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        getValuesBad(full, 0, 6);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
        getValuesBad(full, 1, 5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
        getValuesBad(full, 2, 4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
        getValuesBad(full, 5, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        getValuesBad(empty, 0, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
        setValueGood(full, 0, 55);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
        setValueGood(full, 4, 66);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        // index < 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
        setValueBad(full, -1, 77);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        setValueBad(full, -2, 77);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
        // index > length()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
        setValueBad(full, 5, 77);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        setValueBad(full, 6, 77);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        check(full, new int[] {55, 100, 200, 300, 66});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
        // index < 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
        setValueBad(empty, -1, 77);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        setValueBad(empty, -2, 77);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        // index > length()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
        setValueBad(empty, 0, 77);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        setValueBad(empty, 1, 77);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        setValuesGood(full, new int[] {40, 41, 42});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        setValuesGood(full, new int[] {});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
        check(full, new int[] {40, 41, 42, 300, 66});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
        setValuesGood(full, new int[] {99, 51, 52, 53, 54, 55});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
        setValuesGood(full, new int[] {50});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
        check(full, new int[] {50, 51, 52, 53, 54});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
        setValuesGood(empty, new int[] {});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
        setValuesGood(empty, new int[] {88});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
        setValuesGood(full, 2, new int[] {30, 31, 32, 33, 34, 35}, 0, 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        setValuesGood(full, 0, new int[] {80}, 0, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        check(full, new int[] {80, 51, 30, 31, 32});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
        setValuesGood(full, 0, new int[] {90, 91, 92, 93, 94, 95}, 3, 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        setValuesGood(full, 4, new int[] {81}, 0, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        check(full, new int[] {93, 94, 95, 31, 81});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        setValuesGood(full, 3, new int[] {60, 61, 62, 63}, 0, -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
        setValuesGood(full, 0, new int[] {82}, 0, -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
        check(full, new int[] {82, 94, 95, 60, 61});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
        setValuesGood(full, 3, new int[] {20, 21, 22, 23}, 1, -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
        setValuesGood(full, 1, new int[] {83, 84}, 1, -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
        setValuesGood(full, 1, new int[] {}, 0, -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
        setValuesGood(full, 2, new int[] {}, 0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
        setValuesGood(full, 3, new int[] {99}, 0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
        setValuesGood(full, 4, new int[] {99, 98}, 1, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
        check(full, new int[] {82, 84, 95, 21, 22});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
        setValuesGood(empty, 0, new int[] {}, 0, -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
        setValuesGood(empty, 0, new int[] {}, 0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
        setValuesGood(empty, 0, new int[] {99}, 0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        setValuesGood(empty, 0, new int[] {99, 98}, 1, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        // index < 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
        setValuesBad(full, -1, new int[] {30, 31, 32, 33, 34, 35}, 0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
        setValuesBad(full, -1, new int[] {30, 31, 32, 33, 34, 35}, 0, -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
        setValuesBad(full, -2, new int[] {30, 31, 32, 33, 34, 35}, 0, -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
        setValuesBad(empty, -1, new int[] {}, 0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
        setValuesBad(empty, -2, new int[] {}, 0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
        // index > length()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
        setValuesBad(full, 6, new int[] {30, 31, 32, 33, 34, 35}, 0, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
        setValuesBad(full, 6, new int[] {30, 31, 32, 33, 34, 35}, 0, -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        setValuesBad(empty, 1, new int[] {4}, 0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
        setValuesBad(empty, 1, new int[] {}, 0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
        setValuesBad(empty, 1, new int[] {}, 0, -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
        // srcIndex < 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
        setValuesBad(full, 0, new int[] {90, 91, 92, 93, 94, 95}, -1, 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
        setValuesBad(full, 0, new int[] {90, 91, 92, 93, 94, 95}, -1, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
        setValuesBad(full, 0, new int[] {90, 91, 92, 93, 94, 95}, -1, -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
        setValuesBad(full, 0, new int[] {90, 91, 92, 93, 94, 95}, -2, -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
        setValuesBad(full, 1, new int[] {}, -1, -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
        setValuesBad(full, 2, new int[] {}, -1, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        setValuesBad(empty, 0, new int[] {}, -1, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
        // srcIndex > values.size()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
        setValuesBad(full, 0, new int[] {81}, 2, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
        setValuesBad(full, 0, new int[] {81}, 2, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
        setValuesBad(full, 0, new int[] {81}, 2, -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
        setValuesBad(full, 4, new int[] {}, 1, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
        setValuesBad(full, 1, new int[] {}, 1, -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
        setValuesBad(full, 2, new int[] {}, 1, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
        setValuesBad(empty, 0, new int[] {}, 1, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
        setValuesBad(empty, 0, new int[] {5}, 2, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
        // length < 0 (length != -1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
        setValuesBad(full, 3, new int[] {60, 61, 62, 63}, 0, -2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
        setValuesBad(full, 3, new int[] {}, 0, -2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
        // index + length > length()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
        setValuesBad(full, 0, new int[] {20, 21, 22, 23, 24, 25, 26}, 0, 6);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
        setValuesBad(full, 1, new int[] {20, 21, 22, 23, 24, 25, 26}, 0, 5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
        setValuesBad(full, 2, new int[] {20, 21, 22, 23, 24, 25, 26}, 0, 4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
        setValuesBad(full, 3, new int[] {20, 21, 22, 23, 24, 25, 26}, 0, 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
        setValuesBad(full, 4, new int[] {20, 21, 22, 23, 24, 25, 26}, 0, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
        setValuesBad(full, 5, new int[] {20, 21, 22, 23, 24, 25, 26}, 0, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
        setValuesBad(full, 6, new int[] {20, 21, 22, 23, 24, 25, 26}, 0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
        setValuesBad(full, 2, new int[] {20, 21, 22, 23, 24, 25, 26}, 1, 4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
        setValuesBad(full, 3, new int[] {20, 21, 22, 23, 24, 25, 26}, 1, 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
        setValuesBad(full, 4, new int[] {20, 21, 22, 23, 24, 25, 26}, 2, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
        setValuesBad(full, 5, new int[] {20, 21, 22, 23, 24, 25, 26}, 3, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
        setValuesBad(full, 6, new int[] {20, 21, 22, 23, 24, 25, 26}, 4, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
        setValuesBad(empty, 0, new int[] {6}, 0, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
        // srcIndex + length > values.size()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
        setValuesBad(full, 0, new int[] {82}, 0, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
        setValuesBad(full, 0, new int[] {82}, 1, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
        setValuesBad(full, 0, new int[] {82}, 2, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
        setValuesBad(full, 0, new int[] {20, 21, 22}, 0, 4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
        setValuesBad(full, 0, new int[] {20, 21, 22}, 1, 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
        setValuesBad(full, 0, new int[] {20, 21, 22}, 2, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
        setValuesBad(full, 0, new int[] {20, 21, 22}, 3, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
        setValuesBad(full, 0, new int[] {20, 21, 22}, 4, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
        check(full, new int[] {82, 84, 95, 21, 22});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
         * resume the target until end
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
        listenUntilVMDisconnect();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
         * deal with results of test
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
         * if anything has called failure("foo") testFailed will be true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
        if (!testFailed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
            println("ArrayRangeTest: passed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
            throw new Exception("ArrayRangeTest: failed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
}