Mocked-Clock implementation for public use

I just wanted to bring up the fact that we don't have a public-use mocked-clock implementation.

This can be very helpful for testing. I personally would have been fine implementing one, and in any case I didn't have much trouble finding an existing implementation and copy-pasting it, but this is still something worth addressing for general users.

I'm thinking such implementation should live somewhere in swift-async-algorithms or swift-algorithms. It sounds like a mocked clock should be in swift-algorithms in theory, but in practice it fits swift-async-algorithms better. 1 proof of this is that swift-async-algorithms contains a mocked clock implementation already, just that it's not exposed to the users of the library.

Some implementations that we currently have:

FWIW, I think swift-testing may also be a fitting place to house this: Controllable clock support in `swift-testing`

5 Likes