test/java/util/Collections/AsLifoQueue.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 54,75 **** check(q.offer("b")); check(q.add("c")); equal(q.size(), 3); check(! q.offer("d")); equal(q.size(), 3); ! THROWS(IllegalStateException.class, ! new Fun(){void f(){ q.add("d"); }}); equal(q.size(), 3); equal(q.toString(), "[c, b, a]"); equal(q.peek(), "c"); equal(q.element(), "c"); equal(q.remove(), "c"); equal(q.poll(), "b"); equal(q.peek(), "a"); equal(q.remove(), "a"); ! THROWS(NoSuchElementException.class, ! new Fun(){void f(){ q.remove(); }}); equal(q.poll(), null); check(q.isEmpty()); equal(q.size(), 0); } catch (Throwable t) { unexpected(t); } } --- 54,73 ---- check(q.offer("b")); check(q.add("c")); equal(q.size(), 3); check(! q.offer("d")); equal(q.size(), 3); ! THROWS(IllegalStateException.class, () -> q.add("d")); equal(q.size(), 3); equal(q.toString(), "[c, b, a]"); equal(q.peek(), "c"); equal(q.element(), "c"); equal(q.remove(), "c"); equal(q.poll(), "b"); equal(q.peek(), "a"); equal(q.remove(), "a"); ! THROWS(NoSuchElementException.class, () -> q.remove()); equal(q.poll(), null); check(q.isEmpty()); equal(q.size(), 0); } catch (Throwable t) { unexpected(t); } }
*** 86,96 **** else fail(x + " not equal to " + y);} public static void main(String[] args) throws Throwable { try {realMain(args);} catch (Throwable t) {unexpected(t);} System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new AssertionError("Some tests failed");} ! static abstract class Fun { abstract void f() throws Throwable; } private static void THROWS(Class<? extends Throwable> k, Fun... fs) { for (Fun f : fs) try { f.f(); fail("Expected " + k.getName() + " not thrown"); } catch (Throwable t) { if (k.isAssignableFrom(t.getClass())) pass(); --- 84,94 ---- else fail(x + " not equal to " + y);} public static void main(String[] args) throws Throwable { try {realMain(args);} catch (Throwable t) {unexpected(t);} System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new AssertionError("Some tests failed");} ! @FunctionalInterface interface Fun {void f() throws Throwable;} private static void THROWS(Class<? extends Throwable> k, Fun... fs) { for (Fun f : fs) try { f.f(); fail("Expected " + k.getName() + " not thrown"); } catch (Throwable t) { if (k.isAssignableFrom(t.getClass())) pass();