For package authors: how to test IteratorSize and IteratorEltype?


#1

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:
https://github.com/StephenVavasis/DataStructures.jl/blob/28f49e1c78c33bc8cdbaceb3bf9c110faad38957/src/container_loops.jl

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.


#2

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.