⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tlist.java

📁 是一款用JAVA 编写的编译器 具有很强的编译功能
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
	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.iterator(), ref.iterator()))		throw new AssertionError();	}    }    void test_lastIndexOf_Object() {	System.err.println("test lastIndexOf(Object)");	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 i = -1; i < ref.size(); i++) {		String arg = (i == -1 ? "NOT IN LIST" : ref.get(i));		int expect = ref.lastIndexOf(arg);		int found = l.lastIndexOf(arg);		if (expect != found) 		    throw new AssertionError();	    }	}    }    void test_listIterator() {	System.err.println("test listIterator()");	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.listIterator(), ref.listIterator()))		throw new AssertionError();	}    }    void test_listIterator_int() {	System.err.println("test listIterator(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 i = 0; i < ref.size(); i++) {		if (!equal(l.listIterator(i), ref.listIterator(i)))		    throw new AssertionError();	    }	}    }    void test_remove_int() {	System.err.println("test remove(int)");	for (List<String> l: examples.values()) {	    try {		l.remove(0);		throw new AssertionError();	    } catch (UnsupportedOperationException ex) {	    }	}    }    void test_remove_Object() {	System.err.println("test remove(Object)");	for (List<String> l: examples.values()) {	    boolean hasX = l.contains("X");	    try {		l.remove("X");		if (hasX)		    throw new AssertionError();	    } catch (UnsupportedOperationException ex) {	    }	}    }    void test_removeAll_Collection() {	System.err.println("test removeAll(Collection)");	for (List<String> l: examples.values()) {	    int l_size = l.size();	    for (java.util.List<String> arg: examples.keySet()) {		try {		    boolean modified = l.removeAll(arg);		    if (modified)			throw new AssertionError();		} catch (UnsupportedOperationException e) {		}		if (l.size() != l_size)		    throw new AssertionError();	    }	}    }    void test_retainAll_Collection() {	System.err.println("test retainAll(Collection)");	for (List<String> l: examples.values()) {	    int l_size = l.size();	    for (java.util.List<String> arg: examples.keySet()) {		try {		    boolean modified = l.retainAll(arg);		    if (modified)			throw new AssertionError();		} catch (UnsupportedOperationException e) {		}		if (l.size() != l_size)		    throw new AssertionError();	    }	}    }    void test_set_int_E() {	System.err.println("test set(int,E)");	for (List<String> l: examples.values()) {	    try {		l.set(0, "X");		throw new AssertionError();	    } catch (UnsupportedOperationException ex) {	    }	}    }    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)		throw new 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)))		    throw new 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()))		throw new 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])))		throw new AssertionError();	}    }    void test_prependList_List() {	System.err.println("test prependList(List<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();	    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);		    throw new AssertionError();		}		if (!equal(l, ref))		    throw new AssertionError();		if (!equal(arg, arg_ref))		    throw new 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		throw new AssertionError();	    if (!equal(l, ref)) // orginal should be unchanged		throw new AssertionError();	    if (!equal(expect, found))		throw new 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;    }    static <T> boolean equal(T t1, T t2) {	return (t1 == null ? t2 == null : t1.equals(t2));    }    static <T> boolean equal(Iterator<T> iter1, Iterator<T> iter2) {	if (iter1 == null || iter2 == null)	    return (iter1 == iter2);	while (iter1.hasNext() && iter2.hasNext()) {	    if (!equal(iter1.next(), iter2.next()))		return false;	}	return (!iter1.hasNext() && !iter2.hasNext());    }    static <T> boolean equal(ListIterator<T> iter1, ListIterator<T> iter2) {	if (iter1 == null || iter2 == null)	    return (iter1 == iter2);	if (iter1.previousIndex() != iter2.previousIndex())	    return false;	while (iter1.hasPrevious() && iter2.hasPrevious()) {	    iter1.previous();	    iter2.previous();	}	return equal((Iterator<T>) iter1, (Iterator<T>) iter2);    }    static <T> boolean equal(T[] a1, T[] a2) {	if (a1 == null || a2 == null)	    return (a1 == a2);	if (a1.length != a2.length)	    	    return false;	for (int i = 0; i < a1.length; i++) {	    if (!equal(a1[i], a2[i]))		return false;	}	return true;    }    static <T> java.util.List<T> join(java.util.List<T>... lists) {	java.util.List<T> r = new ArrayList<T>();	for (java.util.List<T> l: lists)	    r.addAll(l);	return r;    }    static <T> java.util.List<T> reverse(java.util.List<T> l) {	java.util.List<T> r = new ArrayList<T>(l.size());	for (T t: l)	    r.add(0, t);	return r;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -