For package authors: how to test IteratorSize and IteratorEltype?


The new iteration protocol involves the functions Base.IteratorSize and Base.IteratorEltype. Is there a recommended methodology for writing tests for these functions? In particular, how are their effects observable in user-level code?

In more detail, I recently rewrote iteration for sorted containers in the DataStructures.jl package; refer to this file:

The logic in this file is complicated, and I don’t have experience with Base.IteratorSize and Base.IteratorEltype, so I want to write tests for the DataStructures.jl package test set to make sure their usage is correct.


Just as a point of clarification, these additions to the iteration protocol have been around quite a while longer than the most recent iteration protocol change.