code
stringlengths
11
173k
docstring
stringlengths
2
593k
func_name
stringlengths
2
189
language
stringclasses
1 value
repo
stringclasses
844 values
path
stringlengths
11
294
url
stringlengths
60
339
license
stringclasses
4 values
public void testPollLast() { ConcurrentLinkedDeque q = populatedDeque(SIZE); for (int i = SIZE - 1; i >= 0; --i) { assertEquals(i, q.pollLast()); } assertNull(q.pollLast()); }
pollLast() succeeds unless empty
ConcurrentLinkedDequeTest::testPollLast
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
Apache-2.0
public void testPoll() { ConcurrentLinkedDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { assertEquals(i, q.poll()); } assertNull(q.poll()); }
poll() succeeds unless empty
ConcurrentLinkedDequeTest::testPoll
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
Apache-2.0
public void testPeek() { ConcurrentLinkedDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { assertEquals(i, q.peek()); assertEquals(i, q.poll()); assertTrue(q.peek() == null || !q.peek().equals(i)); } assertNull(q.peek()); }
peek() returns next element, or null if empty
ConcurrentLinkedDequeTest::testPeek
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
Apache-2.0
public void testElement() { ConcurrentLinkedDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { assertEquals(i, q.element()); assertEquals(i, q.poll()); } try { q.element(); shouldThrow(); } catch (NoSuchElementException success) {} }
element() returns first element, or throws NSEE if empty
ConcurrentLinkedDequeTest::testElement
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
Apache-2.0
public void testRemove() { ConcurrentLinkedDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { assertEquals(i, q.remove()); } try { q.remove(); shouldThrow(); } catch (NoSuchElementException success) {} }
remove() removes next element, or throws NSEE if empty
ConcurrentLinkedDequeTest::testRemove
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
Apache-2.0
public void testRemoveElement() { ConcurrentLinkedDeque q = populatedDeque(SIZE); for (int i = 1; i < SIZE; i += 2) { assertTrue(q.contains(i)); assertTrue(q.remove(i)); assertFalse(q.contains(i)); assertTrue(q.contains(i - 1)); } for (int i = 0; i < SIZE; i += 2) { assertTrue(q.contains(i)); assertTrue(q.remove(i)); assertFalse(q.contains(i)); assertFalse(q.remove(i + 1)); assertFalse(q.contains(i + 1)); } assertTrue(q.isEmpty()); }
remove(x) removes x and returns true if present
ConcurrentLinkedDequeTest::testRemoveElement
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
Apache-2.0
public void testPeekFirst() { ConcurrentLinkedDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { assertEquals(i, q.peekFirst()); assertEquals(i, q.pollFirst()); assertTrue(q.peekFirst() == null || !q.peekFirst().equals(i)); } assertNull(q.peekFirst()); }
peekFirst() returns next element, or null if empty
ConcurrentLinkedDequeTest::testPeekFirst
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
Apache-2.0
public void testPeekLast() { ConcurrentLinkedDeque q = populatedDeque(SIZE); for (int i = SIZE - 1; i >= 0; --i) { assertEquals(i, q.peekLast()); assertEquals(i, q.pollLast()); assertTrue(q.peekLast() == null || !q.peekLast().equals(i)); } assertNull(q.peekLast()); }
peekLast() returns next element, or null if empty
ConcurrentLinkedDequeTest::testPeekLast
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
Apache-2.0
public void testFirstElement() { ConcurrentLinkedDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { assertEquals(i, q.getFirst()); assertEquals(i, q.pollFirst()); } try { q.getFirst(); shouldThrow(); } catch (NoSuchElementException success) {} }
getFirst() returns first element, or throws NSEE if empty
ConcurrentLinkedDequeTest::testFirstElement
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
Apache-2.0
public void testLastElement() { ConcurrentLinkedDeque q = populatedDeque(SIZE); for (int i = SIZE - 1; i >= 0; --i) { assertEquals(i, q.getLast()); assertEquals(i, q.pollLast()); } try { q.getLast(); shouldThrow(); } catch (NoSuchElementException success) {} assertNull(q.peekLast()); }
getLast() returns last element, or throws NSEE if empty
ConcurrentLinkedDequeTest::testLastElement
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
Apache-2.0
public void testRemoveFirst() { ConcurrentLinkedDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { assertEquals(i, q.removeFirst()); } try { q.removeFirst(); shouldThrow(); } catch (NoSuchElementException success) {} assertNull(q.peekFirst()); }
removeFirst() removes first element, or throws NSEE if empty
ConcurrentLinkedDequeTest::testRemoveFirst
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
Apache-2.0
public void testRemoveLast() { ConcurrentLinkedDeque q = populatedDeque(SIZE); for (int i = SIZE - 1; i >= 0; --i) { assertEquals(i, q.removeLast()); } try { q.removeLast(); shouldThrow(); } catch (NoSuchElementException success) {} assertNull(q.peekLast()); }
removeLast() removes last element, or throws NSEE if empty
ConcurrentLinkedDequeTest::testRemoveLast
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
Apache-2.0
public void testRemoveFirstOccurrence() { ConcurrentLinkedDeque q = populatedDeque(SIZE); for (int i = 1; i < SIZE; i += 2) { assertTrue(q.removeFirstOccurrence(new Integer(i))); } for (int i = 0; i < SIZE; i += 2) { assertTrue(q.removeFirstOccurrence(new Integer(i))); assertFalse(q.removeFirstOccurrence(new Integer(i + 1))); } assertTrue(q.isEmpty()); }
removeFirstOccurrence(x) removes x and returns true if present
ConcurrentLinkedDequeTest::testRemoveFirstOccurrence
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
Apache-2.0
public void testRemoveLastOccurrence() { ConcurrentLinkedDeque q = populatedDeque(SIZE); for (int i = 1; i < SIZE; i += 2) { assertTrue(q.removeLastOccurrence(new Integer(i))); } for (int i = 0; i < SIZE; i += 2) { assertTrue(q.removeLastOccurrence(new Integer(i))); assertFalse(q.removeLastOccurrence(new Integer(i + 1))); } assertTrue(q.isEmpty()); }
removeLastOccurrence(x) removes x and returns true if present
ConcurrentLinkedDequeTest::testRemoveLastOccurrence
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
Apache-2.0
public void testContains() { ConcurrentLinkedDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { assertTrue(q.contains(new Integer(i))); q.poll(); assertFalse(q.contains(new Integer(i))); } }
contains(x) reports true when elements added but not yet removed
ConcurrentLinkedDequeTest::testContains
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
Apache-2.0
public void testClear() { ConcurrentLinkedDeque q = populatedDeque(SIZE); q.clear(); assertTrue(q.isEmpty()); assertEquals(0, q.size()); q.add(one); assertFalse(q.isEmpty()); q.clear(); assertTrue(q.isEmpty()); }
clear() removes all elements
ConcurrentLinkedDequeTest::testClear
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
Apache-2.0
public void testContainsAll() { ConcurrentLinkedDeque q = populatedDeque(SIZE); ConcurrentLinkedDeque p = new ConcurrentLinkedDeque(); for (int i = 0; i < SIZE; ++i) { assertTrue(q.containsAll(p)); assertFalse(p.containsAll(q)); p.add(new Integer(i)); } assertTrue(p.containsAll(q)); }
containsAll(c) is true when c contains a subset of elements
ConcurrentLinkedDequeTest::testContainsAll
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
Apache-2.0
public void testRetainAll() { ConcurrentLinkedDeque q = populatedDeque(SIZE); ConcurrentLinkedDeque p = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { boolean changed = q.retainAll(p); if (i == 0) assertFalse(changed); else assertTrue(changed); assertTrue(q.containsAll(p)); assertEquals(SIZE - i, q.size()); p.remove(); } }
retainAll(c) retains only those elements of c and reports true if change
ConcurrentLinkedDequeTest::testRetainAll
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
Apache-2.0
public void testRemoveAll() { for (int i = 1; i < SIZE; ++i) { ConcurrentLinkedDeque q = populatedDeque(SIZE); ConcurrentLinkedDeque p = populatedDeque(i); assertTrue(q.removeAll(p)); assertEquals(SIZE - i, q.size()); for (int j = 0; j < i; ++j) { Integer x = (Integer)(p.remove()); assertFalse(q.contains(x)); } } }
removeAll(c) removes only those elements of c and reports true if changed
ConcurrentLinkedDequeTest::testRemoveAll
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
Apache-2.0
public void testToArray() { ConcurrentLinkedDeque q = populatedDeque(SIZE); Object[] o = q.toArray(); for (int i = 0; i < o.length; i++) assertSame(o[i], q.poll()); }
toArray() contains all elements in FIFO order
ConcurrentLinkedDequeTest::testToArray
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
Apache-2.0
public void testToArray2() { ConcurrentLinkedDeque<Integer> q = populatedDeque(SIZE); Integer[] ints = new Integer[SIZE]; Integer[] array = q.toArray(ints); assertSame(ints, array); for (int i = 0; i < ints.length; i++) assertSame(ints[i], q.poll()); }
toArray(a) contains all elements in FIFO order
ConcurrentLinkedDequeTest::testToArray2
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
Apache-2.0
public void testToArray_NullArg() { ConcurrentLinkedDeque q = populatedDeque(SIZE); try { q.toArray(null); shouldThrow(); } catch (NullPointerException success) {} }
toArray(null) throws NullPointerException
ConcurrentLinkedDequeTest::testToArray_NullArg
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
Apache-2.0
public void testToArray1_BadArg() { ConcurrentLinkedDeque q = populatedDeque(SIZE); try { q.toArray(new String[10]); shouldThrow(); } catch (ArrayStoreException success) {} }
toArray(incompatible array type) throws ArrayStoreException
ConcurrentLinkedDequeTest::testToArray1_BadArg
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
Apache-2.0
public void testIterator() { ConcurrentLinkedDeque q = populatedDeque(SIZE); Iterator it = q.iterator(); int i; for (i = 0; it.hasNext(); i++) assertTrue(q.contains(it.next())); assertEquals(i, SIZE); assertIteratorExhausted(it); }
Iterator iterates through all elements
ConcurrentLinkedDequeTest::testIterator
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
Apache-2.0
public void testEmptyIterator() { Deque c = new ConcurrentLinkedDeque(); assertIteratorExhausted(c.iterator()); assertIteratorExhausted(c.descendingIterator()); }
iterator of empty collection has no elements
ConcurrentLinkedDequeTest::testEmptyIterator
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
Apache-2.0
public void testIteratorOrdering() { final ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); q.add(one); q.add(two); q.add(three); int k = 0; for (Iterator it = q.iterator(); it.hasNext();) { assertEquals(++k, it.next()); } assertEquals(3, k); }
Iterator ordering is FIFO
ConcurrentLinkedDequeTest::testIteratorOrdering
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
Apache-2.0
public void testWeaklyConsistentIteration() { final ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); q.add(one); q.add(two); q.add(three); for (Iterator it = q.iterator(); it.hasNext();) { q.remove(); it.next(); } assertEquals("deque should be empty again", 0, q.size()); }
Modifications do not cause iterators to fail
ConcurrentLinkedDequeTest::testWeaklyConsistentIteration
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
Apache-2.0
public void testIteratorRemove() { final ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); final Random rng = new Random(); for (int iters = 0; iters < 100; ++iters) { int max = rng.nextInt(5) + 2; int split = rng.nextInt(max - 1) + 1; for (int j = 1; j <= max; ++j) q.add(new Integer(j)); Iterator it = q.iterator(); for (int j = 1; j <= split; ++j) assertEquals(it.next(), new Integer(j)); it.remove(); assertEquals(it.next(), new Integer(split + 1)); for (int j = 1; j <= split; ++j) q.remove(new Integer(j)); it = q.iterator(); for (int j = split + 1; j <= max; ++j) { assertEquals(it.next(), new Integer(j)); it.remove(); } assertFalse(it.hasNext()); assertTrue(q.isEmpty()); } }
iterator.remove() removes current element
ConcurrentLinkedDequeTest::testIteratorRemove
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
Apache-2.0
public void testDescendingIterator() { ConcurrentLinkedDeque q = populatedDeque(SIZE); int i = 0; Iterator it = q.descendingIterator(); while (it.hasNext()) { assertTrue(q.contains(it.next())); ++i; } assertEquals(i, SIZE); assertFalse(it.hasNext()); try { it.next(); shouldThrow(); } catch (NoSuchElementException success) {} }
Descending iterator iterates through all elements
ConcurrentLinkedDequeTest::testDescendingIterator
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
Apache-2.0
public void testDescendingIteratorOrdering() { final ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); for (int iters = 0; iters < 100; ++iters) { q.add(new Integer(3)); q.add(new Integer(2)); q.add(new Integer(1)); int k = 0; for (Iterator it = q.descendingIterator(); it.hasNext();) { assertEquals(++k, it.next()); } assertEquals(3, k); q.remove(); q.remove(); q.remove(); } }
Descending iterator ordering is reverse FIFO
ConcurrentLinkedDequeTest::testDescendingIteratorOrdering
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
Apache-2.0
public void testDescendingIteratorRemove() { final ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); final Random rng = new Random(); for (int iters = 0; iters < 100; ++iters) { int max = rng.nextInt(5) + 2; int split = rng.nextInt(max - 1) + 1; for (int j = max; j >= 1; --j) q.add(new Integer(j)); Iterator it = q.descendingIterator(); for (int j = 1; j <= split; ++j) assertEquals(it.next(), new Integer(j)); it.remove(); assertEquals(it.next(), new Integer(split + 1)); for (int j = 1; j <= split; ++j) q.remove(new Integer(j)); it = q.descendingIterator(); for (int j = split + 1; j <= max; ++j) { assertEquals(it.next(), new Integer(j)); it.remove(); } assertFalse(it.hasNext()); assertTrue(q.isEmpty()); } }
descendingIterator.remove() removes current element
ConcurrentLinkedDequeTest::testDescendingIteratorRemove
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
Apache-2.0
public void testToString() { ConcurrentLinkedDeque q = populatedDeque(SIZE); String s = q.toString(); for (int i = 0; i < SIZE; ++i) { assertTrue(s.contains(String.valueOf(i))); } }
toString() contains toStrings of elements
ConcurrentLinkedDequeTest::testToString
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
Apache-2.0
public void testSerialization() throws Exception { Queue x = populatedDeque(SIZE); Queue y = serialClone(x); assertNotSame(x, y); assertEquals(x.size(), y.size()); assertEquals(x.toString(), y.toString()); assertTrue(Arrays.equals(x.toArray(), y.toArray())); while (!x.isEmpty()) { assertFalse(y.isEmpty()); assertEquals(x.remove(), y.remove()); } assertTrue(y.isEmpty()); }
A deserialized serialized deque has same elements in same order
ConcurrentLinkedDequeTest::testSerialization
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
Apache-2.0
public void testNeverContainsNull() { Deque<?>[] qs = { new ConcurrentLinkedDeque<Object>(), populatedDeque(2), }; for (Deque<?> q : qs) { assertFalse(q.contains(null)); try { assertFalse(q.remove(null)); shouldThrow(); } catch (NullPointerException success) {} try { assertFalse(q.removeFirstOccurrence(null)); shouldThrow(); } catch (NullPointerException success) {} try { assertFalse(q.removeLastOccurrence(null)); shouldThrow(); } catch (NullPointerException success) {} } }
contains(null) always return false. remove(null) always throws NullPointerException.
ConcurrentLinkedDequeTest::testNeverContainsNull
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedDequeTest.java
Apache-2.0
public void testConstructor() { assertTrue(new AtomicBoolean(true).get()); assertFalse(new AtomicBoolean(false).get()); }
constructor initializes to given value
AtomicBooleanTest::testConstructor
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/AtomicBooleanTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/AtomicBooleanTest.java
Apache-2.0
public void testConstructor2() { AtomicBoolean ai = new AtomicBoolean(); assertFalse(ai.get()); }
default constructed initializes to false
AtomicBooleanTest::testConstructor2
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/AtomicBooleanTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/AtomicBooleanTest.java
Apache-2.0
public void testGetSet() { AtomicBoolean ai = new AtomicBoolean(true); assertTrue(ai.get()); ai.set(false); assertFalse(ai.get()); ai.set(true); assertTrue(ai.get()); }
get returns the last value set
AtomicBooleanTest::testGetSet
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/AtomicBooleanTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/AtomicBooleanTest.java
Apache-2.0
public void testGetLazySet() { AtomicBoolean ai = new AtomicBoolean(true); assertTrue(ai.get()); ai.lazySet(false); assertFalse(ai.get()); ai.lazySet(true); assertTrue(ai.get()); }
get returns the last value lazySet in same thread
AtomicBooleanTest::testGetLazySet
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/AtomicBooleanTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/AtomicBooleanTest.java
Apache-2.0
public void testCompareAndSet() { AtomicBoolean ai = new AtomicBoolean(true); assertTrue(ai.compareAndSet(true, false)); assertFalse(ai.get()); assertTrue(ai.compareAndSet(false, false)); assertFalse(ai.get()); assertFalse(ai.compareAndSet(true, false)); assertFalse(ai.get()); assertTrue(ai.compareAndSet(false, true)); assertTrue(ai.get()); }
compareAndSet succeeds in changing value if equal to expected else fails
AtomicBooleanTest::testCompareAndSet
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/AtomicBooleanTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/AtomicBooleanTest.java
Apache-2.0
public void testCompareAndSetInMultipleThreads() throws Exception { final AtomicBoolean ai = new AtomicBoolean(true); Thread t = new Thread(new CheckedRunnable() { public void realRun() { while (!ai.compareAndSet(false, true)) Thread.yield(); }}); t.start(); assertTrue(ai.compareAndSet(true, false)); t.join(LONG_DELAY_MS); assertFalse(t.isAlive()); }
compareAndSet in one thread enables another waiting for value to succeed
AtomicBooleanTest::testCompareAndSetInMultipleThreads
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/AtomicBooleanTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/AtomicBooleanTest.java
Apache-2.0
public void testWeakCompareAndSet() { AtomicBoolean ai = new AtomicBoolean(true); do {} while (!ai.weakCompareAndSet(true, false)); assertFalse(ai.get()); do {} while (!ai.weakCompareAndSet(false, false)); assertFalse(ai.get()); do {} while (!ai.weakCompareAndSet(false, true)); assertTrue(ai.get()); }
repeated weakCompareAndSet succeeds in changing value when equal to expected
AtomicBooleanTest::testWeakCompareAndSet
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/AtomicBooleanTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/AtomicBooleanTest.java
Apache-2.0
public void testGetAndSet() { AtomicBoolean ai = new AtomicBoolean(true); assertEquals(true, ai.getAndSet(false)); assertEquals(false, ai.getAndSet(false)); assertEquals(false, ai.getAndSet(true)); assertTrue(ai.get()); }
getAndSet returns previous value and sets to given value
AtomicBooleanTest::testGetAndSet
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/AtomicBooleanTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/AtomicBooleanTest.java
Apache-2.0
public void testSerialization() throws Exception { AtomicBoolean x = new AtomicBoolean(); AtomicBoolean y = serialClone(x); x.set(true); AtomicBoolean z = serialClone(x); assertTrue(x.get()); assertFalse(y.get()); assertTrue(z.get()); }
a deserialized serialized atomic holds same value
AtomicBooleanTest::testSerialization
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/AtomicBooleanTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/AtomicBooleanTest.java
Apache-2.0
public void testToString() { AtomicBoolean ai = new AtomicBoolean(); assertEquals(Boolean.toString(false), ai.toString()); ai.set(true); assertEquals(Boolean.toString(true), ai.toString()); }
toString returns current value.
AtomicBooleanTest::testToString
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/AtomicBooleanTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/AtomicBooleanTest.java
Apache-2.0
private static TreeMap map5() { TreeMap map = new TreeMap(); assertTrue(map.isEmpty()); map.put(one, "A"); map.put(five, "E"); map.put(three, "C"); map.put(two, "B"); map.put(four, "D"); assertFalse(map.isEmpty()); assertEquals(5, map.size()); return map; }
Returns a new map from Integers 1-5 to Strings "A"-"E".
TreeMapTest::map5
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testClear() { TreeMap map = map5(); map.clear(); assertEquals(0, map.size()); }
clear removes all pairs
TreeMapTest::testClear
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testConstructFromSorted() { TreeMap map = map5(); TreeMap map2 = new TreeMap(map); assertEquals(map, map2); }
copy constructor creates map equal to source map
TreeMapTest::testConstructFromSorted
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testEquals() { TreeMap map1 = map5(); TreeMap map2 = map5(); assertEquals(map1, map2); assertEquals(map2, map1); map1.clear(); assertFalse(map1.equals(map2)); assertFalse(map2.equals(map1)); }
Maps with same contents are equal
TreeMapTest::testEquals
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testContainsKey() { TreeMap map = map5(); assertTrue(map.containsKey(one)); assertFalse(map.containsKey(zero)); }
containsKey returns true for contained key
TreeMapTest::testContainsKey
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testContainsValue() { TreeMap map = map5(); assertTrue(map.containsValue("A")); assertFalse(map.containsValue("Z")); }
containsValue returns true for held values
TreeMapTest::testContainsValue
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testGet() { TreeMap map = map5(); assertEquals("A", (String)map.get(one)); TreeMap empty = new TreeMap(); assertNull(empty.get(one)); }
get returns the correct element at the given key, or null if not present
TreeMapTest::testGet
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testIsEmpty() { TreeMap empty = new TreeMap(); TreeMap map = map5(); assertTrue(empty.isEmpty()); assertFalse(map.isEmpty()); }
isEmpty is true of empty map and false for non-empty
TreeMapTest::testIsEmpty
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testFirstKey() { TreeMap map = map5(); assertEquals(one, map.firstKey()); }
firstKey returns first key
TreeMapTest::testFirstKey
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testLastKey() { TreeMap map = map5(); assertEquals(five, map.lastKey()); }
lastKey returns last key
TreeMapTest::testLastKey
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testKeySetToArray() { TreeMap map = map5(); Set s = map.keySet(); Object[] ar = s.toArray(); assertTrue(s.containsAll(Arrays.asList(ar))); assertEquals(5, ar.length); ar[0] = m10; assertFalse(s.containsAll(Arrays.asList(ar))); }
keySet.toArray returns contains all keys
TreeMapTest::testKeySetToArray
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testDescendingKeySetToArray() { TreeMap map = map5(); Set s = map.descendingKeySet(); Object[] ar = s.toArray(); assertEquals(5, ar.length); assertTrue(s.containsAll(Arrays.asList(ar))); ar[0] = m10; assertFalse(s.containsAll(Arrays.asList(ar))); }
descendingkeySet.toArray returns contains all keys
TreeMapTest::testDescendingKeySetToArray
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testKeySet() { TreeMap map = map5(); Set s = map.keySet(); assertEquals(5, s.size()); assertTrue(s.contains(one)); assertTrue(s.contains(two)); assertTrue(s.contains(three)); assertTrue(s.contains(four)); assertTrue(s.contains(five)); }
keySet returns a Set containing all the keys
TreeMapTest::testKeySet
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testKeySetOrder() { TreeMap map = map5(); Set s = map.keySet(); Iterator i = s.iterator(); Integer last = (Integer)i.next(); assertEquals(last, one); int count = 1; while (i.hasNext()) { Integer k = (Integer)i.next(); assertTrue(last.compareTo(k) < 0); last = k; ++count; } assertEquals(5, count); }
keySet is ordered
TreeMapTest::testKeySetOrder
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testKeySetDescendingIteratorOrder() { TreeMap map = map5(); NavigableSet s = map.navigableKeySet(); Iterator i = s.descendingIterator(); Integer last = (Integer)i.next(); assertEquals(last, five); int count = 1; while (i.hasNext()) { Integer k = (Integer)i.next(); assertTrue(last.compareTo(k) > 0); last = k; ++count; } assertEquals(5, count); }
descending iterator of key set is inverse ordered
TreeMapTest::testKeySetDescendingIteratorOrder
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testDescendingKeySetOrder() { TreeMap map = map5(); Set s = map.descendingKeySet(); Iterator i = s.iterator(); Integer last = (Integer)i.next(); assertEquals(last, five); int count = 1; while (i.hasNext()) { Integer k = (Integer)i.next(); assertTrue(last.compareTo(k) > 0); last = k; ++count; } assertEquals(5, count); }
descendingKeySet is ordered
TreeMapTest::testDescendingKeySetOrder
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testDescendingKeySetDescendingIteratorOrder() { TreeMap map = map5(); NavigableSet s = map.descendingKeySet(); Iterator i = s.descendingIterator(); Integer last = (Integer)i.next(); assertEquals(last, one); int count = 1; while (i.hasNext()) { Integer k = (Integer)i.next(); assertTrue(last.compareTo(k) < 0); last = k; ++count; } assertEquals(5, count); }
descending iterator of descendingKeySet is ordered
TreeMapTest::testDescendingKeySetDescendingIteratorOrder
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testValues() { TreeMap map = map5(); Collection s = map.values(); assertEquals(5, s.size()); assertTrue(s.contains("A")); assertTrue(s.contains("B")); assertTrue(s.contains("C")); assertTrue(s.contains("D")); assertTrue(s.contains("E")); }
values collection contains all values
TreeMapTest::testValues
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testEntrySet() { TreeMap map = map5(); Set s = map.entrySet(); assertEquals(5, s.size()); Iterator it = s.iterator(); while (it.hasNext()) { Map.Entry e = (Map.Entry) it.next(); assertTrue( (e.getKey().equals(one) && e.getValue().equals("A")) || (e.getKey().equals(two) && e.getValue().equals("B")) || (e.getKey().equals(three) && e.getValue().equals("C")) || (e.getKey().equals(four) && e.getValue().equals("D")) || (e.getKey().equals(five) && e.getValue().equals("E"))); } }
entrySet contains all pairs
TreeMapTest::testEntrySet
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testDescendingEntrySet() { TreeMap map = map5(); Set s = map.descendingMap().entrySet(); assertEquals(5, s.size()); Iterator it = s.iterator(); while (it.hasNext()) { Map.Entry e = (Map.Entry) it.next(); assertTrue( (e.getKey().equals(one) && e.getValue().equals("A")) || (e.getKey().equals(two) && e.getValue().equals("B")) || (e.getKey().equals(three) && e.getValue().equals("C")) || (e.getKey().equals(four) && e.getValue().equals("D")) || (e.getKey().equals(five) && e.getValue().equals("E"))); } }
descendingEntrySet contains all pairs
TreeMapTest::testDescendingEntrySet
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testEntrySetToArray() { TreeMap map = map5(); Set s = map.entrySet(); Object[] ar = s.toArray(); assertEquals(5, ar.length); for (int i = 0; i < 5; ++i) { assertTrue(map.containsKey(((Map.Entry)(ar[i])).getKey())); assertTrue(map.containsValue(((Map.Entry)(ar[i])).getValue())); } }
entrySet.toArray contains all entries
TreeMapTest::testEntrySetToArray
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testDescendingEntrySetToArray() { TreeMap map = map5(); Set s = map.descendingMap().entrySet(); Object[] ar = s.toArray(); assertEquals(5, ar.length); for (int i = 0; i < 5; ++i) { assertTrue(map.containsKey(((Map.Entry)(ar[i])).getKey())); assertTrue(map.containsValue(((Map.Entry)(ar[i])).getValue())); } }
descendingEntrySet.toArray contains all entries
TreeMapTest::testDescendingEntrySetToArray
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testPutAll() { TreeMap empty = new TreeMap(); TreeMap map = map5(); empty.putAll(map); assertEquals(5, empty.size()); assertTrue(empty.containsKey(one)); assertTrue(empty.containsKey(two)); assertTrue(empty.containsKey(three)); assertTrue(empty.containsKey(four)); assertTrue(empty.containsKey(five)); }
putAll adds all key-value pairs from the given map
TreeMapTest::testPutAll
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testRemove() { TreeMap map = map5(); map.remove(five); assertEquals(4, map.size()); assertFalse(map.containsKey(five)); }
remove removes the correct key-value pair from the map
TreeMapTest::testRemove
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testLowerEntry() { TreeMap map = map5(); Map.Entry e1 = map.lowerEntry(three); assertEquals(two, e1.getKey()); Map.Entry e2 = map.lowerEntry(six); assertEquals(five, e2.getKey()); Map.Entry e3 = map.lowerEntry(one); assertNull(e3); Map.Entry e4 = map.lowerEntry(zero); assertNull(e4); }
lowerEntry returns preceding entry.
TreeMapTest::testLowerEntry
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testHigherEntry() { TreeMap map = map5(); Map.Entry e1 = map.higherEntry(three); assertEquals(four, e1.getKey()); Map.Entry e2 = map.higherEntry(zero); assertEquals(one, e2.getKey()); Map.Entry e3 = map.higherEntry(five); assertNull(e3); Map.Entry e4 = map.higherEntry(six); assertNull(e4); }
higherEntry returns next entry.
TreeMapTest::testHigherEntry
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testFloorEntry() { TreeMap map = map5(); Map.Entry e1 = map.floorEntry(three); assertEquals(three, e1.getKey()); Map.Entry e2 = map.floorEntry(six); assertEquals(five, e2.getKey()); Map.Entry e3 = map.floorEntry(one); assertEquals(one, e3.getKey()); Map.Entry e4 = map.floorEntry(zero); assertNull(e4); }
floorEntry returns preceding entry.
TreeMapTest::testFloorEntry
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testCeilingEntry() { TreeMap map = map5(); Map.Entry e1 = map.ceilingEntry(three); assertEquals(three, e1.getKey()); Map.Entry e2 = map.ceilingEntry(zero); assertEquals(one, e2.getKey()); Map.Entry e3 = map.ceilingEntry(five); assertEquals(five, e3.getKey()); Map.Entry e4 = map.ceilingEntry(six); assertNull(e4); }
ceilingEntry returns next entry.
TreeMapTest::testCeilingEntry
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testLowerKey() { TreeMap q = map5(); Object e1 = q.lowerKey(three); assertEquals(two, e1); Object e2 = q.lowerKey(six); assertEquals(five, e2); Object e3 = q.lowerKey(one); assertNull(e3); Object e4 = q.lowerKey(zero); assertNull(e4); }
lowerKey returns preceding element
TreeMapTest::testLowerKey
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testHigherKey() { TreeMap q = map5(); Object e1 = q.higherKey(three); assertEquals(four, e1); Object e2 = q.higherKey(zero); assertEquals(one, e2); Object e3 = q.higherKey(five); assertNull(e3); Object e4 = q.higherKey(six); assertNull(e4); }
higherKey returns next element
TreeMapTest::testHigherKey
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testFloorKey() { TreeMap q = map5(); Object e1 = q.floorKey(three); assertEquals(three, e1); Object e2 = q.floorKey(six); assertEquals(five, e2); Object e3 = q.floorKey(one); assertEquals(one, e3); Object e4 = q.floorKey(zero); assertNull(e4); }
floorKey returns preceding element
TreeMapTest::testFloorKey
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testCeilingKey() { TreeMap q = map5(); Object e1 = q.ceilingKey(three); assertEquals(three, e1); Object e2 = q.ceilingKey(zero); assertEquals(one, e2); Object e3 = q.ceilingKey(five); assertEquals(five, e3); Object e4 = q.ceilingKey(six); assertNull(e4); }
ceilingKey returns next element
TreeMapTest::testCeilingKey
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testPollFirstEntry() { TreeMap map = map5(); Map.Entry e = map.pollFirstEntry(); assertEquals(one, e.getKey()); assertEquals("A", e.getValue()); e = map.pollFirstEntry(); assertEquals(two, e.getKey()); map.put(one, "A"); e = map.pollFirstEntry(); assertEquals(one, e.getKey()); assertEquals("A", e.getValue()); e = map.pollFirstEntry(); assertEquals(three, e.getKey()); map.remove(four); e = map.pollFirstEntry(); assertEquals(five, e.getKey()); try { e.setValue("A"); shouldThrow(); } catch (UnsupportedOperationException success) {} e = map.pollFirstEntry(); assertNull(e); }
pollFirstEntry returns entries in order
TreeMapTest::testPollFirstEntry
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testPollLastEntry() { TreeMap map = map5(); Map.Entry e = map.pollLastEntry(); assertEquals(five, e.getKey()); assertEquals("E", e.getValue()); e = map.pollLastEntry(); assertEquals(four, e.getKey()); map.put(five, "E"); e = map.pollLastEntry(); assertEquals(five, e.getKey()); assertEquals("E", e.getValue()); e = map.pollLastEntry(); assertEquals(three, e.getKey()); map.remove(two); e = map.pollLastEntry(); assertEquals(one, e.getKey()); try { e.setValue("E"); shouldThrow(); } catch (UnsupportedOperationException success) {} e = map.pollLastEntry(); assertNull(e); }
pollLastEntry returns entries in order
TreeMapTest::testPollLastEntry
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testSize() { TreeMap map = map5(); TreeMap empty = new TreeMap(); assertEquals(0, empty.size()); assertEquals(5, map.size()); }
size returns the correct values
TreeMapTest::testSize
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testToString() { TreeMap map = map5(); String s = map.toString(); for (int i = 1; i <= 5; ++i) { assertTrue(s.contains(String.valueOf(i))); } }
toString contains toString of elements
TreeMapTest::testToString
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testGet_NullPointerException() { TreeMap c = map5(); try { c.get(null); shouldThrow(); } catch (NullPointerException success) {} }
get(null) of nonempty map throws NPE
TreeMapTest::testGet_NullPointerException
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testContainsKey_NullPointerException() { TreeMap c = map5(); try { c.containsKey(null); shouldThrow(); } catch (NullPointerException success) {} }
containsKey(null) of nonempty map throws NPE
TreeMapTest::testContainsKey_NullPointerException
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testRemove1_NullPointerException() { TreeMap c = new TreeMap(); c.put("sadsdf", "asdads"); try { c.remove(null); shouldThrow(); } catch (NullPointerException success) {} }
remove(null) throws NPE for nonempty map
TreeMapTest::testRemove1_NullPointerException
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testSerialization() throws Exception { NavigableMap x = map5(); NavigableMap y = serialClone(x); assertNotSame(x, y); assertEquals(x.size(), y.size()); assertEquals(x.toString(), y.toString()); assertEquals(x, y); assertEquals(y, x); }
A deserialized map equals original
TreeMapTest::testSerialization
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testSubMapContents() { TreeMap map = map5(); NavigableMap sm = map.subMap(two, true, four, false); assertEquals(two, sm.firstKey()); assertEquals(three, sm.lastKey()); assertEquals(2, sm.size()); assertFalse(sm.containsKey(one)); assertTrue(sm.containsKey(two)); assertTrue(sm.containsKey(three)); assertFalse(sm.containsKey(four)); assertFalse(sm.containsKey(five)); Iterator i = sm.keySet().iterator(); Object k; k = (Integer)(i.next()); assertEquals(two, k); k = (Integer)(i.next()); assertEquals(three, k); assertFalse(i.hasNext()); Iterator r = sm.descendingKeySet().iterator(); k = (Integer)(r.next()); assertEquals(three, k); k = (Integer)(r.next()); assertEquals(two, k); assertFalse(r.hasNext()); Iterator j = sm.keySet().iterator(); j.next(); j.remove(); assertFalse(map.containsKey(two)); assertEquals(4, map.size()); assertEquals(1, sm.size()); assertEquals(three, sm.firstKey()); assertEquals(three, sm.lastKey()); assertEquals("C", sm.remove(three)); assertTrue(sm.isEmpty()); assertEquals(3, map.size()); }
subMap returns map with keys in requested range
TreeMapTest::testSubMapContents
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testHeadMapContents() { TreeMap map = map5(); NavigableMap sm = map.headMap(four, false); assertTrue(sm.containsKey(one)); assertTrue(sm.containsKey(two)); assertTrue(sm.containsKey(three)); assertFalse(sm.containsKey(four)); assertFalse(sm.containsKey(five)); Iterator i = sm.keySet().iterator(); Object k; k = (Integer)(i.next()); assertEquals(one, k); k = (Integer)(i.next()); assertEquals(two, k); k = (Integer)(i.next()); assertEquals(three, k); assertFalse(i.hasNext()); sm.clear(); assertTrue(sm.isEmpty()); assertEquals(2, map.size()); assertEquals(four, map.firstKey()); }
headMap returns map with keys in requested range
TreeMapTest::testHeadMapContents
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testTailMapContents() { TreeMap map = map5(); NavigableMap sm = map.tailMap(two, true); assertFalse(sm.containsKey(one)); assertTrue(sm.containsKey(two)); assertTrue(sm.containsKey(three)); assertTrue(sm.containsKey(four)); assertTrue(sm.containsKey(five)); Iterator i = sm.keySet().iterator(); Object k; k = (Integer)(i.next()); assertEquals(two, k); k = (Integer)(i.next()); assertEquals(three, k); k = (Integer)(i.next()); assertEquals(four, k); k = (Integer)(i.next()); assertEquals(five, k); assertFalse(i.hasNext()); Iterator r = sm.descendingKeySet().iterator(); k = (Integer)(r.next()); assertEquals(five, k); k = (Integer)(r.next()); assertEquals(four, k); k = (Integer)(r.next()); assertEquals(three, k); k = (Integer)(r.next()); assertEquals(two, k); assertFalse(r.hasNext()); Iterator ei = sm.entrySet().iterator(); Map.Entry e; e = (Map.Entry)(ei.next()); assertEquals(two, e.getKey()); assertEquals("B", e.getValue()); e = (Map.Entry)(ei.next()); assertEquals(three, e.getKey()); assertEquals("C", e.getValue()); e = (Map.Entry)(ei.next()); assertEquals(four, e.getKey()); assertEquals("D", e.getValue()); e = (Map.Entry)(ei.next()); assertEquals(five, e.getKey()); assertEquals("E", e.getValue()); assertFalse(i.hasNext()); NavigableMap ssm = sm.tailMap(four, true); assertEquals(four, ssm.firstKey()); assertEquals(five, ssm.lastKey()); assertEquals("D", ssm.remove(four)); assertEquals(1, ssm.size()); assertEquals(3, sm.size()); assertEquals(4, map.size()); }
headMap returns map with keys in requested range
TreeMapTest::testTailMapContents
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testRecursiveSubMaps() throws Exception { int mapSize = expensiveTests ? 1000 : 100; Class cl = TreeMap.class; NavigableMap<Integer, Integer> map = newMap(cl); bs = new BitSet(mapSize); populate(map, mapSize); check(map, 0, mapSize - 1, true); check(map.descendingMap(), 0, mapSize - 1, false); mutateMap(map, 0, mapSize - 1); check(map, 0, mapSize - 1, true); check(map.descendingMap(), 0, mapSize - 1, false); bashSubMap(map.subMap(0, true, mapSize, false), 0, mapSize - 1, true); }
Submaps of submaps subdivide correctly
TreeMapTest::testRecursiveSubMaps
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
Apache-2.0
public void testInvoke() { RecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FibAction f = new FibAction(8); assertNull(f.invoke()); assertEquals(21, f.result); checkCompletedNormally(f); }}; testInvokeOnPool(mainPool(), a); }
invoke returns when task completes normally. isCompletedAbnormally and isCancelled return false for normally completed tasks. getRawResult of a RecursiveAction returns null;
FailingFibAction::testInvoke
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/RecursiveActionTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/RecursiveActionTest.java
Apache-2.0
public void testQuietlyInvoke() { RecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FibAction f = new FibAction(8); f.quietlyInvoke(); assertEquals(21, f.result); checkCompletedNormally(f); }}; testInvokeOnPool(mainPool(), a); }
quietlyInvoke task returns when task completes normally. isCompletedAbnormally and isCancelled return false for normally completed tasks
FailingFibAction::testQuietlyInvoke
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/RecursiveActionTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/RecursiveActionTest.java
Apache-2.0
public void testForkJoin() { RecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FibAction f = new FibAction(8); assertSame(f, f.fork()); assertNull(f.join()); assertEquals(21, f.result); checkCompletedNormally(f); }}; testInvokeOnPool(mainPool(), a); }
join of a forked task returns when task completes
FailingFibAction::testForkJoin
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/RecursiveActionTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/RecursiveActionTest.java
Apache-2.0
public void testJoinIgnoresInterrupts() { RecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FibAction f = new FibAction(8); final Thread myself = Thread.currentThread(); // test join() assertSame(f, f.fork()); myself.interrupt(); assertTrue(myself.isInterrupted()); assertNull(f.join()); Thread.interrupted(); assertEquals(21, f.result); checkCompletedNormally(f); f = new FibAction(8); f.cancel(true); assertSame(f, f.fork()); myself.interrupt(); assertTrue(myself.isInterrupted()); try { f.join(); shouldThrow(); } catch (CancellationException success) { Thread.interrupted(); checkCancelled(f); } f = new FibAction(8); f.completeExceptionally(new FJException()); assertSame(f, f.fork()); myself.interrupt(); assertTrue(myself.isInterrupted()); try { f.join(); shouldThrow(); } catch (FJException success) { Thread.interrupted(); checkCompletedAbnormally(f, success); } // test quietlyJoin() f = new FibAction(8); assertSame(f, f.fork()); myself.interrupt(); assertTrue(myself.isInterrupted()); f.quietlyJoin(); Thread.interrupted(); assertEquals(21, f.result); checkCompletedNormally(f); f = new FibAction(8); f.cancel(true); assertSame(f, f.fork()); myself.interrupt(); assertTrue(myself.isInterrupted()); f.quietlyJoin(); Thread.interrupted(); checkCancelled(f); f = new FibAction(8); f.completeExceptionally(new FJException()); assertSame(f, f.fork()); myself.interrupt(); assertTrue(myself.isInterrupted()); f.quietlyJoin(); Thread.interrupted(); checkCompletedAbnormally(f, f.getException()); }}; testInvokeOnPool(mainPool(), a); a.reinitialize(); testInvokeOnPool(singletonPool(), a); }
join/quietlyJoin of a forked task succeeds in the presence of interrupts
FailingFibAction::testJoinIgnoresInterrupts
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/RecursiveActionTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/RecursiveActionTest.java
Apache-2.0
public void testJoinIgnoresInterruptsOutsideForkJoinPool() { final SynchronousQueue<FibAction[]> sq = new SynchronousQueue<FibAction[]>(); RecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws InterruptedException { FibAction[] fibActions = new FibAction[6]; for (int i = 0; i < fibActions.length; i++) fibActions[i] = new FibAction(8); fibActions[1].cancel(false); fibActions[2].completeExceptionally(new FJException()); fibActions[4].cancel(true); fibActions[5].completeExceptionally(new FJException()); for (int i = 0; i < fibActions.length; i++) fibActions[i].fork(); sq.put(fibActions); helpQuiesce(); }}; Runnable r = new CheckedRunnable() { public void realRun() throws InterruptedException { FibAction[] fibActions = sq.take(); FibAction f; final Thread myself = Thread.currentThread(); // test join() ------------ f = fibActions[0]; assertFalse(ForkJoinTask.inForkJoinPool()); myself.interrupt(); assertTrue(myself.isInterrupted()); assertNull(f.join()); assertTrue(Thread.interrupted()); assertEquals(21, f.result); checkCompletedNormally(f); f = fibActions[1]; myself.interrupt(); assertTrue(myself.isInterrupted()); try { f.join(); shouldThrow(); } catch (CancellationException success) { assertTrue(Thread.interrupted()); checkCancelled(f); } f = fibActions[2]; myself.interrupt(); assertTrue(myself.isInterrupted()); try { f.join(); shouldThrow(); } catch (FJException success) { assertTrue(Thread.interrupted()); checkCompletedAbnormally(f, success); } // test quietlyJoin() --------- f = fibActions[3]; myself.interrupt(); assertTrue(myself.isInterrupted()); f.quietlyJoin(); assertTrue(Thread.interrupted()); assertEquals(21, f.result); checkCompletedNormally(f); f = fibActions[4]; myself.interrupt(); assertTrue(myself.isInterrupted()); f.quietlyJoin(); assertTrue(Thread.interrupted()); checkCancelled(f); f = fibActions[5]; myself.interrupt(); assertTrue(myself.isInterrupted()); f.quietlyJoin(); assertTrue(Thread.interrupted()); assertTrue(f.getException() instanceof FJException); checkCompletedAbnormally(f, f.getException()); }}; Thread t; t = newStartedThread(r); testInvokeOnPool(mainPool(), a); awaitTermination(t); a.reinitialize(); t = newStartedThread(r); testInvokeOnPool(singletonPool(), a); awaitTermination(t); }
join/quietlyJoin of a forked task when not in ForkJoinPool succeeds in the presence of interrupts
FailingFibAction::testJoinIgnoresInterruptsOutsideForkJoinPool
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/RecursiveActionTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/RecursiveActionTest.java
Apache-2.0
public void testForkGet() { RecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { FibAction f = new FibAction(8); assertSame(f, f.fork()); assertNull(f.get()); assertEquals(21, f.result); checkCompletedNormally(f); }}; testInvokeOnPool(mainPool(), a); }
get of a forked task returns when task completes
FailingFibAction::testForkGet
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/RecursiveActionTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/RecursiveActionTest.java
Apache-2.0
public void testForkTimedGet() { RecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { FibAction f = new FibAction(8); assertSame(f, f.fork()); assertNull(f.get(5L, SECONDS)); assertEquals(21, f.result); checkCompletedNormally(f); }}; testInvokeOnPool(mainPool(), a); }
timed get of a forked task returns when task completes
FailingFibAction::testForkTimedGet
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/RecursiveActionTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/RecursiveActionTest.java
Apache-2.0
public void testForkTimedGetNPE() { RecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { FibAction f = new FibAction(8); assertSame(f, f.fork()); try { f.get(5L, null); shouldThrow(); } catch (NullPointerException success) {} }}; testInvokeOnPool(mainPool(), a); }
timed get with null time unit throws NPE
FailingFibAction::testForkTimedGetNPE
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/RecursiveActionTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/RecursiveActionTest.java
Apache-2.0
public void testForkQuietlyJoin() { RecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FibAction f = new FibAction(8); assertSame(f, f.fork()); f.quietlyJoin(); assertEquals(21, f.result); checkCompletedNormally(f); }}; testInvokeOnPool(mainPool(), a); }
quietlyJoin of a forked task returns when task completes
FailingFibAction::testForkQuietlyJoin
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/RecursiveActionTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/RecursiveActionTest.java
Apache-2.0
public void testForkHelpQuiesce() { RecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FibAction f = new FibAction(8); assertSame(f, f.fork()); helpQuiesce(); while (!f.isDone()) // wait out race ; assertEquals(21, f.result); assertEquals(0, getQueuedTaskCount()); checkCompletedNormally(f); }}; testInvokeOnPool(mainPool(), a); }
helpQuiesce returns when tasks are complete. getQueuedTaskCount returns 0 when quiescent
FailingFibAction::testForkHelpQuiesce
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/RecursiveActionTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/RecursiveActionTest.java
Apache-2.0
public void testAbnormalInvoke() { RecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FailingFibAction f = new FailingFibAction(8); try { f.invoke(); shouldThrow(); } catch (FJException success) { checkCompletedAbnormally(f, success); } }}; testInvokeOnPool(mainPool(), a); }
invoke task throws exception when task completes abnormally
FailingFibAction::testAbnormalInvoke
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/RecursiveActionTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/RecursiveActionTest.java
Apache-2.0
public void testAbnormalQuietlyInvoke() { RecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FailingFibAction f = new FailingFibAction(8); f.quietlyInvoke(); assertTrue(f.getException() instanceof FJException); checkCompletedAbnormally(f, f.getException()); }}; testInvokeOnPool(mainPool(), a); }
quietlyInvoke task returns when task completes abnormally
FailingFibAction::testAbnormalQuietlyInvoke
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/RecursiveActionTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/RecursiveActionTest.java
Apache-2.0