### Question:
History implements Iterable<Object> { @NonNull public static Builder emptyBuilder() { return new Builder(Collections.emptyList()); } private  History(List<Object> history); @NonNull static Builder emptyBuilder(); @NonNull static History single(@NonNull Object key); @NonNull Iterable<T> framesFromBottom(); @NonNull Iterable<T> framesFromTop(); @Deprecated @NonNull Iterator<T> reverseIterator(); @Deprecated @NonNull @Override Iterator<Object> iterator(); int size(); @NonNull T top(); @NonNull T peek(int index); @NonNull Builder buildUpon(); @Override String toString();  }### Answer:
@Test public void builderPopToExplodesOnMissingState() { History.Builder builder = History.emptyBuilder(); builder.push(ABLE); builder.push(BAKER); builder.push(CHARLIE); try { builder.popTo(new Object()); fail("Missing state object, should have thrown"); } catch (IllegalArgumentException ignored) { } }
@Test public void builderPopExplodesIfCountIsTooLarge() { History.Builder builder = History.emptyBuilder(); builder.push(ABLE); builder.push(BAKER); builder.push(CHARLIE); try { builder.pop(4); fail("Count is too large, should have thrown"); } catch (IllegalArgumentException ignored) { } }
@Test public void emptyBuilderPopThrows() { try { History.emptyBuilder().pop(); fail("Should throw"); } catch (IllegalStateException e) { } }
@Test public void isEmpty() { final History.Builder builder = History.emptyBuilder(); assertThat(builder.isEmpty()).isTrue(); builder.push("foo"); assertThat(builder.isEmpty()).isFalse(); builder.pop(); assertThat(builder.isEmpty()).isTrue(); }