/* * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
/* * @test * @bug 6267067 6351336 6389198 * @summary unit test for javac List * @modules jdk.compiler/com.sun.tools.javac.util
*/
void test_size() {
System.err.println("test size()"); for (Map.Entry<java.util.List<String>,List<String>> e: examples.entrySet()) {
java.util.List<String> ref = e.getKey();
List<String> l = e.getValue(); int expect = ref.size(); int found = l.size(); if (expect != found) thrownew AssertionError();
}
}
void test_subList_int_int() {
System.err.println("test subList(int,int)"); for (Map.Entry<java.util.List<String>,List<String>> e: examples.entrySet()) {
java.util.List<String> ref = e.getKey();
List<String> l = e.getValue(); for (int lwb = 0; lwb < ref.size(); lwb++) { for (int upb = lwb; upb <= ref.size(); upb++) { if (!equal(l.subList(lwb, upb), ref.subList(lwb,upb))) thrownew AssertionError();
}
}
}
}
void test_toArray() {
System.err.println("test toArray()"); for (Map.Entry<java.util.List<String>,List<String>> e: examples.entrySet()) {
java.util.List<String> ref = e.getKey();
List<String> l = e.getValue(); if (!equal(l.toArray(), ref.toArray())) thrownew AssertionError();
}
}
void test_toArray_TArray() {
System.err.println("test toArray(E[])"); for (Map.Entry<java.util.List<String>,List<String>> e: examples.entrySet()) {
java.util.List<String> ref = e.getKey();
List<String> l = e.getValue(); if (!equal(l.toArray(new String[0]), ref.toArray(new String[0]))) thrownew AssertionError();
}
}
void test_prependList_List() {
System.err.println("test prependList(List)"); for (Map.Entry<java.util.List<String>,List<String>> e: examples.entrySet()) {
java.util.List<String> ref = e.getKey();
List<String> l = e.getValue(); for (Map.Entry<java.util.List<String>, List<String>> arg_e: examples.entrySet()) {
java.util.List<String> arg_ref = arg_e.getKey();
List<String> arg = arg_e.getValue();
java.util.List<String> expect = join(arg, ref);
List<String> found = l.prependList(arg); // verify results, and that original and arg lists are unchanged if (!equal(expect, found)) {
System.err.println("ref: " + ref);
System.err.println("l: " + l);
System.err.println("arg: " + arg);
System.err.println("expect: " + expect);
System.err.println("found: " + found); thrownew AssertionError();
} if (!equal(l, ref)) thrownew AssertionError(); if (!equal(arg, arg_ref)) thrownew AssertionError();
}
}
}
void test_reverse() {
System.err.println("test reverse()"); for (Map.Entry<java.util.List<String>,List<String>> e: examples.entrySet()) {
java.util.List<String> ref = e.getKey();
List<String> l = e.getValue();
java.util.List<String> expect = reverse(ref);
List<String> found = l.reverse(); if (l.size() < 2 && found != l) // reverse of empty or singleton list is itself thrownew AssertionError(); if (!equal(l, ref)) // orginal should be unchanged thrownew AssertionError(); if (!equal(expect, found)) thrownew AssertionError();
}
}
static <T> com.sun.tools.javac.util.List<T> createList(List<T> d) {
com.sun.tools.javac.util.List<T> l = com.sun.tools.javac.util.List.nil(); for (ListIterator<T> iter = d.listIterator(d.size()); iter.hasPrevious(); )
l = l.prepend(iter.previous()); return l;
}
static <T> com.sun.tools.javac.util.List<T> createList(T... d) {
com.sun.tools.javac.util.List<T> l = com.sun.tools.javac.util.List.nil(); for (int i = d.length - 1; i >= 0; i--)
l = l.prepend(d[i]); return l;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.