CMLModuleStack { public ICMLModule pop() { return stack[--sp]; }  void push(ICMLModule item); int length(); ICMLModule pop(); ICMLModule current(); @Override String toString(); boolean endsWith(ICMLModule lastElement); boolean endsWith(ICMLModule oneButLast, ICMLModule lastElement); boolean endsWith(ICMLModule twoButLast, ICMLModule oneButLast, ICMLModule lastElement);  }
@Test public void testPop() { CMLModuleStack stack = new CMLModuleStack(); ICMLModule first = new CMLCoreModule((IChemFile) null); ICMLModule second = new CMLCoreModule((IChemFile) null); ICMLModule third = new CMLCoreModule((IChemFile) null); stack.push(first); stack.push(second); stack.push(third); Assert.assertEquals(third, stack.pop()); Assert.assertEquals(second, stack.pop()); Assert.assertEquals(first, stack.pop()); try { Assert.assertEquals("doesNotExist", stack.pop()); Assert.fail("Should have received an ArrayIndexOutOfBoundsException"); } catch (Exception exception) { } }