News for hackers. Stuff that matters.
Re:10 years ago, someone wrote a test for servo that include... by WorldMaker on Monday April 20, 2026 @12:32PM (#47836682)
Similarly, I like .NET's TimeProvider abstraction [1]. You pass a TimeProvider to your functions. At runtime you can provide the default TimeProvider.System. When testing FakeTimeProvider has a lot of handy tools to do deterministic testing.

One of the further benefits of .NET's TimeProvider is that it can also be provided to low level async methods like `await Task.Delay(time, timeProvider, cancellationToken)` which also increases the testability of general asynchronous code in a deterministic sandbox once you learn to pass TimeProvider to even low level calls that take an optional one.

[1] https://learn.microsoft.com/en-us/dotnet/standard/datetime/t...

Re:10 years ago, someone wrote a test for servo that include... by rzzzt on Monday April 20, 2026 @04:07PM (#47839833)
Java has an interface named InstantSource for this purpose: https://docs.oracle.com/en/java/javase/17/docs/api/java.base...
Re:10 years ago, someone wrote a test for servo that include... by layer8 on Monday April 20, 2026 @04:30PM (#47840096)
Paradoxically, InstantSource may have a delay. ;)