equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
35 check(Arrays.equals(q.toArray(), elts)); |
35 check(Arrays.equals(q.toArray(), elts)); |
36 } |
36 } |
37 |
37 |
38 private static void noMoreElements(final Iterator<Integer> it) { |
38 private static void noMoreElements(final Iterator<Integer> it) { |
39 for (int j = 0; j < 2; j++) { |
39 for (int j = 0; j < 2; j++) { |
40 THROWS(NoSuchElementException.class, |
40 THROWS(NoSuchElementException.class, () -> it.next()); |
41 new Fun() { void f() { it.next(); }}); |
|
42 check(! it.hasNext()); |
41 check(! it.hasNext()); |
43 } |
42 } |
44 } |
43 } |
45 |
44 |
46 private static void removeIsCurrentlyIllegal(final Iterator<Integer> it) { |
45 private static void removeIsCurrentlyIllegal(final Iterator<Integer> it) { |
47 for (int j = 0; j < 2; j++) { |
46 for (int j = 0; j < 2; j++) { |
48 THROWS(IllegalStateException.class, |
47 THROWS(IllegalStateException.class, () -> it.remove()); |
49 new Fun() { void f() { it.remove(); }}); |
|
50 } |
48 } |
51 } |
49 } |
52 |
50 |
53 private static void remove(Iterator<Integer> it, |
51 private static void remove(Iterator<Integer> it, |
54 Queue<Integer> q) { |
52 Queue<Integer> q) { |
144 else fail(x + " not equal to " + y);} |
142 else fail(x + " not equal to " + y);} |
145 public static void main(String[] args) throws Throwable { |
143 public static void main(String[] args) throws Throwable { |
146 try {realMain(args);} catch (Throwable t) {unexpected(t);} |
144 try {realMain(args);} catch (Throwable t) {unexpected(t);} |
147 System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); |
145 System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); |
148 if (failed > 0) throw new AssertionError("Some tests failed");} |
146 if (failed > 0) throw new AssertionError("Some tests failed");} |
149 private static abstract class Fun {abstract void f() throws Throwable;} |
147 interface Fun {void f() throws Throwable;} |
150 static void THROWS(Class<? extends Throwable> k, Fun... fs) { |
148 static void THROWS(Class<? extends Throwable> k, Fun... fs) { |
151 for (Fun f : fs) |
149 for (Fun f : fs) |
152 try { f.f(); fail("Expected " + k.getName() + " not thrown"); } |
150 try { f.f(); fail("Expected " + k.getName() + " not thrown"); } |
153 catch (Throwable t) { |
151 catch (Throwable t) { |
154 if (k.isAssignableFrom(t.getClass())) pass(); |
152 if (k.isAssignableFrom(t.getClass())) pass(); |