jdk/test/java/util/Collection/MOAT.java
author martin
Sat, 10 May 2008 12:14:53 -0700
changeset 494 320ce398f07e
parent 493 b8102e80be10
child 2428 e63d91602813
permissions -rw-r--r--
6691215: (coll) IdentityHashMap.containsValue(null) returns true when null value not present Reviewed-by: dl, chegar, alanb Contributed-by: scottb@google.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
493
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
     2
 * Copyright 2005-2008 Sun Microsystems, Inc.  All Rights Reserved.
2
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     6207984 6272521 6192552 6269713 6197726 6260652 5073546 4137464
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 *          4155650 4216399 4294891 6282555 6318622 6355327 6383475 6420753
494
320ce398f07e 6691215: (coll) IdentityHashMap.containsValue(null) returns true when null value not present
martin
parents: 493
diff changeset
    28
 *          6431845 4802633 6570566 6570575 6570631 6570924 6691185 6691215
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * @summary Run many tests on many Collection and Map implementations
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * @author  Martin Buchholz
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
/* Mother Of All (Collection) Tests
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * Testing of collection classes is often spotty, because many tests
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * need to be performed on many implementations, but the onus on
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * writing the tests falls on the engineer introducing the new
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * The idea of this mega-test is that:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * An engineer adding a new collection implementation could simply add
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * their new implementation to a list of implementations in this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * test's main method.  Any general purpose Collection<Integer> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * Map<Integer,Integer> class is appropriate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * An engineer fixing a regression could add their regression test here and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * simultaneously test all other implementations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
import java.io.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
import java.util.concurrent.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
import static java.util.Collections.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
public class MOAT {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    public static void realMain(String[] args) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        testCollection(new LinkedHashSet<Integer>());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        testCollection(new HashSet<Integer>());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        testCollection(new Vector<Integer>());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        testCollection(new Vector<Integer>().subList(0,0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        testCollection(new ArrayDeque<Integer>());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        testCollection(new ArrayList<Integer>());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        testCollection(new ArrayList<Integer>().subList(0,0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        testCollection(new LinkedList<Integer>());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        testCollection(new LinkedList<Integer>().subList(0,0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        testCollection(new TreeSet<Integer>());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        testCollection(new CopyOnWriteArrayList<Integer>());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        testCollection(new CopyOnWriteArrayList<Integer>().subList(0,0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        testCollection(new CopyOnWriteArraySet<Integer>());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        testCollection(new PriorityQueue<Integer>());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        testCollection(new PriorityBlockingQueue<Integer>());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        testCollection(new ArrayBlockingQueue<Integer>(20));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        testCollection(new LinkedBlockingQueue<Integer>(20));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        testCollection(new LinkedBlockingDeque<Integer>(20));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        testCollection(new ConcurrentLinkedQueue<Integer>());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        testCollection(new ConcurrentSkipListSet<Integer>());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        testCollection(Arrays.asList(new Integer(42)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        testCollection(Arrays.asList(1,2,3));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        testCollection(nCopies(25,1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        testImmutableList(nCopies(25,1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        testImmutableList(unmodifiableList(Arrays.asList(1,2,3)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        testMap(new HashMap<Integer,Integer>());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        testMap(new LinkedHashMap<Integer,Integer>());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        testMap(new WeakHashMap<Integer,Integer>());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        testMap(new IdentityHashMap<Integer,Integer>());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        testMap(new TreeMap<Integer,Integer>());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        testMap(new Hashtable<Integer,Integer>());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        testMap(new ConcurrentHashMap<Integer,Integer>(10, 0.5f));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        testMap(new ConcurrentSkipListMap<Integer,Integer>());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        // Empty collections
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        final List<Integer> emptyArray = Arrays.asList(new Integer[]{});
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        testCollection(emptyArray);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        testEmptyList(emptyArray);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        THROWS(IndexOutOfBoundsException.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
               new Fun(){void f(){ emptyArray.set(0,1); }});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        THROWS(UnsupportedOperationException.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
               new Fun(){void f(){ emptyArray.add(0,1); }});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        List<Integer> noOne = nCopies(0,1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        testCollection(noOne);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        testEmptyList(noOne);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        testImmutableList(noOne);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        Set<Integer> emptySet = emptySet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        testCollection(emptySet);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        testEmptySet(emptySet);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        testEmptySet(EMPTY_SET);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        testImmutableSet(emptySet);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        List<Integer> emptyList = emptyList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        testCollection(emptyList);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        testEmptyList(emptyList);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        testEmptyList(EMPTY_LIST);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        testImmutableList(emptyList);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        Map<Integer,Integer> emptyMap = emptyMap();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        testMap(emptyMap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        testEmptyMap(emptyMap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        testEmptyMap(EMPTY_MAP);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        testImmutableMap(emptyMap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        // Singleton collections
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        Set<Integer> singletonSet = singleton(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        equal(singletonSet.size(), 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        testCollection(singletonSet);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        testImmutableSet(singletonSet);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        List<Integer> singletonList = singletonList(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        equal(singletonList.size(), 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        testCollection(singletonList);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        testImmutableList(singletonList);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        testImmutableList(singletonList.subList(0,1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        testImmutableList(singletonList.subList(0,1).subList(0,1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        testEmptyList(singletonList.subList(0,0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        testEmptyList(singletonList.subList(0,0).subList(0,0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        Map<Integer,Integer> singletonMap = singletonMap(1,2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        equal(singletonMap.size(), 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        testMap(singletonMap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        testImmutableMap(singletonMap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    private static void checkContainsSelf(Collection<Integer> c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        check(c.containsAll(c));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        check(c.containsAll(Arrays.asList(c.toArray())));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        check(c.containsAll(Arrays.asList(c.toArray(new Integer[0]))));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    private static void checkContainsEmpty(Collection<Integer> c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        check(c.containsAll(new ArrayList<Integer>()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
493
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   158
    private static <T> void testEmptyCollection(Collection<T> c) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        check(c.isEmpty());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        equal(c.size(), 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        equal(c.toString(),"[]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        equal(c.toArray().length, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        equal(c.toArray(new Object[0]).length, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        Object[] a = new Object[1]; a[0] = Boolean.TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        equal(c.toArray(a), a);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        equal(a[0], null);
493
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   168
        testEmptyIterator(c.iterator());
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   169
    }
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   170
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   171
    static <T> void testEmptyIterator(final Iterator<T> it) {
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   172
        if (rnd.nextBoolean())
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   173
            check(! it.hasNext());
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   174
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   175
        THROWS(NoSuchElementException.class,
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   176
               new Fun(){void f(){ it.next(); }});
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   177
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   178
        try { it.remove(); }
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   179
        catch (IllegalStateException _) { pass(); }
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   180
        catch (UnsupportedOperationException _) { pass(); }
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   181
        catch (Throwable t) { unexpected(t); }
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   182
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   183
        if (rnd.nextBoolean())
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   184
            check(! it.hasNext());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    private static void testEmptyList(List<?> c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        testEmptyCollection(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        equal(c.hashCode(), 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        equal2(c, Collections.<Integer>emptyList());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
493
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   193
    private static <T> void testEmptySet(Set<T> c) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        testEmptyCollection(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        equal(c.hashCode(), 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        equal2(c, Collections.<Integer>emptySet());
493
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   197
        if (c instanceof NavigableSet<?>)
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   198
            testEmptyIterator(((NavigableSet<T>)c).descendingIterator());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    private static void testImmutableCollection(final Collection<Integer> c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        THROWS(UnsupportedOperationException.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
               new Fun(){void f(){ c.add(99); }},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
               new Fun(){void f(){ c.addAll(singleton(99)); }});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        if (! c.isEmpty()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
            final Integer first = c.iterator().next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
            THROWS(UnsupportedOperationException.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                   new Fun(){void f(){ c.clear(); }},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                   new Fun(){void f(){ c.remove(first); }},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                   new Fun(){void f(){ c.removeAll(singleton(first)); }},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                   new Fun(){void f(){ c.retainAll(emptyList()); }}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                   );
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
    private static void testImmutableSet(final Set<Integer> c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        testImmutableCollection(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    private static void testImmutableList(final List<Integer> c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        testList(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        testImmutableCollection(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        THROWS(UnsupportedOperationException.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
               new Fun(){void f(){ c.set(0,42); }},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
               new Fun(){void f(){ c.add(0,42); }},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
               new Fun(){void f(){ c.addAll(0,singleton(86)); }});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        if (! c.isEmpty())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            THROWS(UnsupportedOperationException.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                   new Fun(){void f(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
                           Iterator<Integer> it = c.iterator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                           it.next(); it.remove();}},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                   new Fun(){void f(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
                           ListIterator<Integer> it = c.listIterator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
                           it.next(); it.remove();}});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    private static void clear(Collection<Integer> c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        try { c.clear(); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        catch (Throwable t) { unexpected(t); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        testEmptyCollection(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
493
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   243
    private static <K,V> void testEmptyMap(final Map<K,V> m) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        check(m.isEmpty());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        equal(m.size(), 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        equal(m.toString(),"{}");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        testEmptySet(m.keySet());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        testEmptySet(m.entrySet());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        testEmptyCollection(m.values());
494
320ce398f07e 6691215: (coll) IdentityHashMap.containsValue(null) returns true when null value not present
martin
parents: 493
diff changeset
   250
320ce398f07e 6691215: (coll) IdentityHashMap.containsValue(null) returns true when null value not present
martin
parents: 493
diff changeset
   251
        try { check(! m.containsValue(null)); }
320ce398f07e 6691215: (coll) IdentityHashMap.containsValue(null) returns true when null value not present
martin
parents: 493
diff changeset
   252
        catch (NullPointerException _) { /* OK */ }
320ce398f07e 6691215: (coll) IdentityHashMap.containsValue(null) returns true when null value not present
martin
parents: 493
diff changeset
   253
        try { check(! m.containsKey(null)); }
320ce398f07e 6691215: (coll) IdentityHashMap.containsValue(null) returns true when null value not present
martin
parents: 493
diff changeset
   254
        catch (NullPointerException _) { /* OK */ }
320ce398f07e 6691215: (coll) IdentityHashMap.containsValue(null) returns true when null value not present
martin
parents: 493
diff changeset
   255
        check(! m.containsValue(1));
320ce398f07e 6691215: (coll) IdentityHashMap.containsValue(null) returns true when null value not present
martin
parents: 493
diff changeset
   256
        check(! m.containsKey(1));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    private static void testImmutableMap(final Map<Integer,Integer> m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        THROWS(UnsupportedOperationException.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
               new Fun(){void f(){ m.put(1,1); }},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
               new Fun(){void f(){ m.putAll(singletonMap(1,1)); }});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        if (! m.isEmpty()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
            final Integer first = m.keySet().iterator().next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
            THROWS(UnsupportedOperationException.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
                   new Fun(){void f(){ m.remove(first); }},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
                   new Fun(){void f(){ m.clear(); }});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
            final Map.Entry<Integer,Integer> me
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
                = m.entrySet().iterator().next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
            Integer key = me.getKey();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
            Integer val = me.getValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
            THROWS(UnsupportedOperationException.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
                   new Fun(){void f(){ me.setValue(3); }});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
            equal(key, me.getKey());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
            equal(val, me.getValue());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        testImmutableSet(m.keySet());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        testImmutableCollection(m.values());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        //testImmutableSet(m.entrySet());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    private static void clear(Map<?,?> m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        try { m.clear(); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        catch (Throwable t) { unexpected(t); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        testEmptyMap(m);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    private static void oneElement(Collection<Integer> c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        clear(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
            check(c.add(-42));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
            equal(c.toString(), "[-42]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
            if (c instanceof Set) check(! c.add(-42));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        } catch (Throwable t) { unexpected(t); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        check(! c.isEmpty()); check(c.size() == 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    private static boolean supportsAdd(Collection<Integer> c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        try { check(c.add(778347983)); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        catch (UnsupportedOperationException t) { return false; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        catch (Throwable t) { unexpected(t); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
            check(c.contains(778347983));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
            check(c.remove(778347983));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
        } catch (Throwable t) { unexpected(t); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    private static boolean supportsRemove(Collection<Integer> c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
        try { check(! c.remove(19134032)); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
        catch (UnsupportedOperationException t) { return false; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        catch (Throwable t) { unexpected(t); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    private static void checkFunctionalInvariants(Collection<Integer> c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
            checkContainsSelf(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
            checkContainsEmpty(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
            check(c.size() != 0 ^ c.isEmpty());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
                int size = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
                for (Integer i : c) size++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
                check(c.size() == size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
            check(c.toArray().length == c.size());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
            check(c.toArray().getClass() == Object[].class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
                  ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
                  // !!!!
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
                  // 6260652: (coll) Arrays.asList(x).toArray().getClass()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
                  // should be Object[].class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
                  (c.getClass().getName().equals("java.util.Arrays$ArrayList"))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
                  );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
            for (int size : new int[]{0,1,c.size(), c.size()+1}) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
                Integer[] a = c.toArray(new Integer[size]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
                check((size > c.size()) || a.length == c.size());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
                int i = 0; for (Integer j : c) check(a[i++] == j);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
                check((size <= c.size()) || (a[c.size()] == null));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
                check(a.getClass() == Integer[].class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
            check(c.equals(c));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
            if (c instanceof Serializable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
                //System.out.printf("Serializing %s%n", c.getClass().getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
                    Object clone = serialClone(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
                    equal(c instanceof Serializable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
                          clone instanceof Serializable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
                    equal(c instanceof RandomAccess,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
                          clone instanceof RandomAccess);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
                    if ((c instanceof List) || (c instanceof Set))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
                        equal(c, clone);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
                    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
                        equal(new HashSet<Integer>(c),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
                              new HashSet<Integer>(serialClone(c)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
                } catch (Error xxx) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
                    if (! (xxx.getCause() instanceof NotSerializableException))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
                        throw xxx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        catch (Throwable t) { unexpected(t); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    //----------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
    // If add(null) succeeds, contains(null) & remove(null) should succeed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
    //----------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
    private static void testNullElement(Collection<Integer> c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        // !!!! 5018849: (coll) TreeSet.contains(null) does not agree with Javadoc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        if (c instanceof TreeSet) return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
            check(c.add(null));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
            if (c.size() == 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
                equal(c.toString(), "[null]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
                checkFunctionalInvariants(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
                check(c.contains(null));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
                check(c.remove(null));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
            catch (Throwable t) { unexpected(t); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
        catch (NullPointerException e) { /* OK */ }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
        catch (Throwable t) { unexpected(t); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
    //----------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    // If add("x") succeeds, contains("x") & remove("x") should succeed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
    //----------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    @SuppressWarnings("unchecked")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
    private static void testStringElement(Collection<Integer> c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
        Collection x = (Collection)c; // Make type-unsafe
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
            check(x.add("x"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
                check(x.contains("x"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
                check(x.remove("x"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
            } catch (Throwable t) { unexpected(t); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        catch (ClassCastException e) { /* OK */ }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        catch (Throwable t) { unexpected(t); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
    private static void testConcurrentCollection(Collection<Integer> c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
            c.add(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
            Iterator<Integer> it = c.iterator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
            check(it.hasNext());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
            clear(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
            check(it.next() instanceof Integer); // No CME
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
            check(c.isEmpty());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
        catch (Throwable t) { unexpected(t); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    private static void testQueue(Queue<Integer> q) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
        q.clear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
        for (int i = 0; i < 5; i++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
            q.add(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        equal(q.size(), 5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
        checkFunctionalInvariants(q);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        q.poll();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
        equal(q.size(), 4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
        checkFunctionalInvariants(q);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
    private static void testList(final List<Integer> l) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
        //----------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
        // 4802633: (coll) AbstractList.addAll(-1,emptyCollection)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
        // doesn't throw IndexOutOfBoundsException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
        //----------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
            l.addAll(-1, Collections.<Integer>emptyList());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
            fail("Expected IndexOutOfBoundsException not thrown");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
        catch (UnsupportedOperationException _) {/* OK */}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
        catch (IndexOutOfBoundsException _) {/* OK */}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
        catch (Throwable t) { unexpected(t); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
//      equal(l instanceof Serializable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
//            l.subList(0,0) instanceof Serializable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
        if (l.subList(0,0) instanceof Serializable)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
            check(l instanceof Serializable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
        equal(l instanceof RandomAccess,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
              l.subList(0,0) instanceof RandomAccess);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
    private static void testCollection(Collection<Integer> c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
        System.out.println("\n==> " + c.getClass().getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
        checkFunctionalInvariants(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
        if (! supportsAdd(c)) return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
        //System.out.println("add() supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
493
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   462
        if (c instanceof NavigableSet) {
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   463
            System.out.println("NavigableSet tests...");
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   464
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   465
            NavigableSet<Integer> ns = (NavigableSet<Integer>)c;
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   466
            testNavigableSet(ns);
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   467
            testNavigableSet(ns.headSet(6, false));
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   468
            testNavigableSet(ns.headSet(5, true));
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   469
            testNavigableSet(ns.tailSet(0, false));
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   470
            testNavigableSet(ns.tailSet(1, true));
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   471
            testNavigableSet(ns.subSet(0, false, 5, true));
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   472
            testNavigableSet(ns.subSet(1, true, 6, false));
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   473
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
        if (c instanceof Queue)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
            testQueue((Queue<Integer>)c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
        if (c instanceof List)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
            testList((List<Integer>)c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
        check(supportsRemove(c));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
            oneElement(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
            checkFunctionalInvariants(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
        catch (Throwable t) { unexpected(t); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
        clear(c);      testNullElement(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
        oneElement(c); testNullElement(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
        clear(c);      testStringElement(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
        oneElement(c); testStringElement(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
        if (c.getClass().getName().matches(".*concurrent.*"))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
            testConcurrentCollection(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
        //----------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
        // The "all" operations should throw NPE when passed null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
        //----------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
            oneElement(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
                c.removeAll(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
                fail("Expected NullPointerException");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
            catch (NullPointerException e) { pass(); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
            catch (Throwable t) { unexpected(t); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
            oneElement(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
                c.retainAll(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
                fail("Expected NullPointerException");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
            catch (NullPointerException e) { pass(); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
            catch (Throwable t) { unexpected(t); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
            oneElement(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
                c.addAll(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
                fail("Expected NullPointerException");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
            catch (NullPointerException e) { pass(); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
            catch (Throwable t) { unexpected(t); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
            oneElement(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
                c.containsAll(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
                fail("Expected NullPointerException");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
            catch (NullPointerException e) { pass(); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
            catch (Throwable t) { unexpected(t); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
    //----------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
    // Map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
    //----------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
    private static void checkFunctionalInvariants(Map<Integer,Integer> m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
        check(m.keySet().size() == m.entrySet().size());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
        check(m.keySet().size() == m.size());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
        checkFunctionalInvariants(m.keySet());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
        checkFunctionalInvariants(m.values());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
        check(m.size() != 0 ^ m.isEmpty());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
    private static void testMap(Map<Integer,Integer> m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
        System.out.println("\n==> " + m.getClass().getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
        if (m instanceof ConcurrentMap)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
            testConcurrentMap((ConcurrentMap<Integer,Integer>) m);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
493
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   553
        if (m instanceof NavigableMap) {
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   554
            System.out.println("NavigableMap tests...");
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   555
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   556
            NavigableMap<Integer,Integer> nm =
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   557
                (NavigableMap<Integer,Integer>) m;
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   558
            testNavigableMap(nm);
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   559
            testNavigableMap(nm.headMap(6, false));
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   560
            testNavigableMap(nm.headMap(5, true));
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   561
            testNavigableMap(nm.tailMap(0, false));
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   562
            testNavigableMap(nm.tailMap(1, true));
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   563
            testNavigableMap(nm.subMap(1, true, 6, false));
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   564
            testNavigableMap(nm.subMap(0, false, 5, true));
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   565
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
        checkFunctionalInvariants(m);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
        if (supportsClear(m)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
            try { clear(m); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
            catch (Throwable t) { unexpected(t); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
        if (supportsPut(m)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
                check(m.put(3333, 77777) == null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
                check(m.put(9134, 74982) == null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
                check(m.get(9134) == 74982);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
                check(m.put(9134, 1382) == 74982);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
                check(m.get(9134) == 1382);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
                check(m.size() == 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
                checkFunctionalInvariants(m);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
                checkNPEConsistency(m);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
            catch (Throwable t) { unexpected(t); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
    private static boolean supportsPut(Map<Integer,Integer> m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
        // We're asking for .equals(...) semantics
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
        if (m instanceof IdentityHashMap) return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
        try { check(m.put(778347983,12735) == null); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
        catch (UnsupportedOperationException t) { return false; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
        catch (Throwable t) { unexpected(t); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
            check(m.containsKey(778347983));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
            check(m.remove(778347983) != null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
        } catch (Throwable t) { unexpected(t); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
    private static boolean supportsClear(Map<?,?> m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
        try { m.clear(); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
        catch (UnsupportedOperationException t) { return false; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
        catch (Throwable t) { unexpected(t); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
    //----------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
    // ConcurrentMap
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
    //----------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
    private static void testConcurrentMap(ConcurrentMap<Integer,Integer> m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
        System.out.println("ConcurrentMap tests...");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
            clear(m);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
            check(m.putIfAbsent(18357,7346) == null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
            check(m.containsKey(18357));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
            check(m.putIfAbsent(18357,8263) == 7346);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
            try { m.putIfAbsent(18357,null); fail("NPE"); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
            catch (NullPointerException t) { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
            check(m.containsKey(18357));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
            check(! m.replace(18357,8888,7777));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
            check(m.containsKey(18357));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
            try { m.replace(18357,null,7777); fail("NPE"); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
            catch (NullPointerException t) { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
            check(m.containsKey(18357));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
            check(m.get(18357) == 7346);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
            check(m.replace(18357,7346,5555));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
            check(m.replace(18357,5555,7346));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
            check(m.get(18357) == 7346);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
            check(m.replace(92347,7834) == null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
            try { m.replace(18357,null); fail("NPE"); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
            catch (NullPointerException t) { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
            check(m.replace(18357,7346) == 7346);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
            check(m.replace(18357,5555) == 7346);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
            check(m.get(18357) == 5555);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
            check(m.replace(18357,7346) == 5555);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
            check(m.get(18357) == 7346);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
            check(! m.remove(18357,9999));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
            check(m.get(18357) == 7346);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
            check(m.containsKey(18357));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
            check(! m.remove(18357,null)); // 6272521
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
            check(m.get(18357) == 7346);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
            check(m.remove(18357,7346));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
            check(m.get(18357) == null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
            check(! m.containsKey(18357));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
            check(m.isEmpty());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
            m.putIfAbsent(1,2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
            check(m.size() == 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
            check(! m.remove(1,null));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
            check(! m.remove(1,null));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
            check(! m.remove(1,1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
            check(m.remove(1,2));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
            check(m.isEmpty());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
            testEmptyMap(m);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
        catch (Throwable t) { unexpected(t); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
    private static void throwsConsistently(Class<? extends Throwable> k,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
                                           Iterable<Fun> fs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
        List<Class<? extends Throwable>> threw
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
            = new ArrayList<Class<? extends Throwable>>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
        for (Fun f : fs)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
            try { f.f(); threw.add(null); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
            catch (Throwable t) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
                check(k.isAssignableFrom(t.getClass()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
                threw.add(t.getClass());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
        if (new HashSet<Object>(threw).size() != 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
            fail(threw.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
    private static <T> void checkNPEConsistency(final Map<T,Integer> m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
        m.clear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
        final ConcurrentMap<T,Integer> cm = (m instanceof ConcurrentMap)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
            ? (ConcurrentMap<T,Integer>) m
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
            : null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
        List<Fun> fs = new ArrayList<Fun>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
        fs.add(new Fun(){void f(){ check(! m.containsKey(null));}});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
        fs.add(new Fun(){void f(){ equal(m.remove(null), null);}});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
        fs.add(new Fun(){void f(){ equal(m.get(null), null);}});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
        if (cm != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
            fs.add(new Fun(){void f(){ check(! cm.remove(null,null));}});}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
        throwsConsistently(NullPointerException.class, fs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
        fs.clear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
        final Map<T,Integer> sm = singletonMap(null,1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
        fs.add(new Fun(){void f(){ equal(m.put(null,1), null); m.clear();}});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
        fs.add(new Fun(){void f(){ m.putAll(sm); m.clear();}});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
        if (cm != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
            fs.add(new Fun(){void f(){ check(! cm.remove(null,null));}});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
            fs.add(new Fun(){void f(){ equal(cm.putIfAbsent(null,1), 1);}});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
            fs.add(new Fun(){void f(){ equal(cm.replace(null,1), null);}});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
            fs.add(new Fun(){void f(){ equal(cm.replace(null,1, 1), 1);}});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
        throwsConsistently(NullPointerException.class, fs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
    //----------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
    // NavigableMap
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
    //----------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
    private static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
        checkNavigableMapKeys(NavigableMap<Integer,Integer> m,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
                              Integer i,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
                              Integer lower,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
                              Integer floor,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
                              Integer ceiling,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
                              Integer higher) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
        equal(m.lowerKey(i),   lower);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
        equal(m.floorKey(i),   floor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
        equal(m.ceilingKey(i), ceiling);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
        equal(m.higherKey(i),  higher);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
    private static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
        checkNavigableSetKeys(NavigableSet<Integer> m,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
                              Integer i,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
                              Integer lower,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
                              Integer floor,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
                              Integer ceiling,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
                              Integer higher) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
        equal(m.lower(i),   lower);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
        equal(m.floor(i),   floor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
        equal(m.ceiling(i), ceiling);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
        equal(m.higher(i),  higher);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
    static final Random rnd = new Random();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
    static void equalNext(final Iterator<?> it, Object expected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
        if (rnd.nextBoolean())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
            check(it.hasNext());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
        equal(it.next(), expected);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
    private static void testNavigableMap(NavigableMap<Integer,Integer> m)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
        clear(m);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
        checkNavigableMapKeys(m, 1, null, null, null, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
        equal(m.put(1, 2), null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
        equal(m.put(3, 4), null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
        equal(m.put(5, 9), null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
        equal(m.put(1, 2), 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
        equal(m.put(3, 4), 4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
        equal(m.put(5, 6), 9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
        checkNavigableMapKeys(m, 0, null, null,    1,    1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
        checkNavigableMapKeys(m, 1, null,    1,    1,    3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
        checkNavigableMapKeys(m, 2,    1,    1,    3,    3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
        checkNavigableMapKeys(m, 3,    1,    3,    3,    5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
        checkNavigableMapKeys(m, 5,    3,    5,    5, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
        checkNavigableMapKeys(m, 6,    5,    5, null, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
493
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   765
        for (final Iterator<Integer> it :
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   766
                 (Iterator<Integer>[])
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   767
                 new Iterator<?>[] {
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   768
                     m.descendingKeySet().iterator(),
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   769
                     m.navigableKeySet().descendingIterator()}) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
            equalNext(it, 5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
            equalNext(it, 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
            equalNext(it, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
            check(! it.hasNext());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
            THROWS(NoSuchElementException.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
                   new Fun(){void f(){it.next();}});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
            final Iterator<Map.Entry<Integer,Integer>> it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
                = m.descendingMap().entrySet().iterator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
            check(it.hasNext()); equal(it.next().getKey(), 5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
            check(it.hasNext()); equal(it.next().getKey(), 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
            check(it.hasNext()); equal(it.next().getKey(), 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
            check(! it.hasNext());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
            THROWS(NoSuchElementException.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
                   new Fun(){void f(){it.next();}});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
    private static void testNavigableSet(NavigableSet<Integer> s) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
        clear(s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
        checkNavigableSetKeys(s, 1, null, null, null, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
        check(s.add(1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
        check(s.add(3));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
        check(s.add(5));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
        check(! s.add(1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
        check(! s.add(3));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
        check(! s.add(5));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
        checkNavigableSetKeys(s, 0, null, null,    1,    1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
        checkNavigableSetKeys(s, 1, null,    1,    1,    3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
        checkNavigableSetKeys(s, 2,    1,    1,    3,    3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
        checkNavigableSetKeys(s, 3,    1,    3,    3,    5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
        checkNavigableSetKeys(s, 5,    3,    5,    5, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
        checkNavigableSetKeys(s, 6,    5,    5, null, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
493
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   810
        for (final Iterator<Integer> it :
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   811
                 (Iterator<Integer>[])
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   812
                 new Iterator<?>[] {
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   813
                     s.descendingIterator(),
b8102e80be10 6691185: (coll) TreeMap.navigableKeySet's descendingIterator method starts at first instead of last entry
martin
parents: 2
diff changeset
   814
                     s.descendingSet().iterator()}) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
            equalNext(it, 5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
            equalNext(it, 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
            equalNext(it, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
            check(! it.hasNext());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
            THROWS(NoSuchElementException.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
                   new Fun(){void f(){it.next();}});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
    //--------------------- Infrastructure ---------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
    static volatile int passed = 0, failed = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
    static void pass() { passed++; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
    static void fail() { failed++; Thread.dumpStack(); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
    static void fail(String msg) { System.out.println(msg); fail(); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
    static void unexpected(Throwable t) { failed++; t.printStackTrace(); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
    static void check(boolean cond) { if (cond) pass(); else fail(); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
    static void equal(Object x, Object y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
        if (x == null ? y == null : x.equals(y)) pass();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
        else {System.out.println(x + " not equal to " + y); fail();}}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
    static void equal2(Object x, Object y) {equal(x, y); equal(y, x);}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
    public static void main(String[] args) throws Throwable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
        try { realMain(args); } catch (Throwable t) { unexpected(t); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
        System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
        if (failed > 0) throw new Exception("Some tests failed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
    private static abstract class Fun {abstract void f() throws Throwable;}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
    private static void THROWS(Class<? extends Throwable> k, Fun... fs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
          for (Fun f : fs)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
              try { f.f(); fail("Expected " + k.getName() + " not thrown"); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
              catch (Throwable t) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
                  if (k.isAssignableFrom(t.getClass())) pass();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
                  else unexpected(t);}}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
    static byte[] serializedForm(Object obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
            new ObjectOutputStream(baos).writeObject(obj);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
            return baos.toByteArray();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
        } catch (IOException e) { throw new Error(e); }}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
    static Object readObject(byte[] bytes)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
        throws IOException, ClassNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
        InputStream is = new ByteArrayInputStream(bytes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
        return new ObjectInputStream(is).readObject();}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
    @SuppressWarnings("unchecked")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
    static <T> T serialClone(T obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
        try { return (T) readObject(serializedForm(obj)); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
        catch (Exception e) { throw new Error(e); }}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
}