1 |
|
/* |
2 |
< |
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. |
2 |
> |
* Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. |
3 |
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
|
* |
5 |
|
* This code is free software; you can redistribute it and/or modify it |
84 |
|
try { |
85 |
|
final Iterator it = c.iterator(); |
86 |
|
THROWS(NoSuchElementException.class, |
87 |
< |
new Fun() {void f() { while (true) it.next(); }}); |
87 |
> |
() -> { while (true) it.next(); }); |
88 |
|
try { it.remove(); } |
89 |
< |
catch (UnsupportedOperationException ok) { return; } |
89 |
> |
catch (UnsupportedOperationException exc) { return; } |
90 |
|
pass(); |
91 |
|
} catch (Throwable t) { unexpected(t); } |
92 |
|
|
96 |
|
final ListIterator it = list.listIterator(0); |
97 |
|
it.next(); |
98 |
|
final Object x = it.previous(); |
99 |
< |
THROWS(NoSuchElementException.class, |
100 |
< |
new Fun() {void f() { it.previous(); }}); |
99 |
> |
THROWS(NoSuchElementException.class, () -> it.previous()); |
100 |
|
try { it.remove(); } |
101 |
< |
catch (UnsupportedOperationException ok) { return; } |
101 |
> |
catch (UnsupportedOperationException exc) { return; } |
102 |
|
pass(); |
103 |
|
check(! list.get(0).equals(x)); |
104 |
|
} catch (Throwable t) { unexpected(t); } |
107 |
|
final ListIterator it = list.listIterator(list.size()); |
108 |
|
it.previous(); |
109 |
|
final Object x = it.next(); |
110 |
< |
THROWS(NoSuchElementException.class, |
112 |
< |
new Fun() {void f() { it.next(); }}); |
110 |
> |
THROWS(NoSuchElementException.class, () -> it.next()); |
111 |
|
try { it.remove(); } |
112 |
< |
catch (UnsupportedOperationException ok) { return; } |
112 |
> |
catch (UnsupportedOperationException exc) { return; } |
113 |
|
pass(); |
114 |
|
check(! list.get(list.size()-1).equals(x)); |
115 |
|
} catch (Throwable t) { unexpected(t); } |
130 |
|
try {realMain(args);} catch (Throwable t) {unexpected(t);} |
131 |
|
System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); |
132 |
|
if (failed > 0) throw new AssertionError("Some tests failed");} |
133 |
< |
private abstract static class Fun {abstract void f() throws Throwable;} |
133 |
> |
interface Fun {void f() throws Throwable;} |
134 |
|
static void THROWS(Class<? extends Throwable> k, Fun... fs) { |
135 |
|
for (Fun f : fs) |
136 |
|
try { f.f(); fail("Expected " + k.getName() + " not thrown"); } |