ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/jtreg/util/Collection/IteratorAtEnd.java
(Generate patch)

Comparing jsr166/src/test/jtreg/util/Collection/IteratorAtEnd.java (file contents):
Revision 1.5 by jsr166, Mon Feb 2 07:33:31 2015 UTC vs.
Revision 1.6 by jsr166, Tue Sep 15 08:10:35 2015 UTC

# Line 1 | Line 1
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
# Line 84 | Line 84 | public class IteratorAtEnd {
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  
# Line 96 | Line 96 | public class IteratorAtEnd {
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); }
# Line 108 | Line 107 | public class IteratorAtEnd {
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); }
# Line 132 | Line 130 | public class IteratorAtEnd {
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"); }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines