Added unit test for SPARK-3224

It took me about 30 minutes to write this test, and given your familiarity with the code I'm sure you could have written it more quickly! I think the example set by the committers is critical to setting the tone of the community, and I'd argue strongly that this should be a community in which changes to core code paths (e.g., the scheduler) should not be done without adding unit tests, especially when the unit tests do not take long to write.  I hope you'll consider writing a test yourself next time!

This test doesn't cover some of the corner cases we discussed on your PR; I'd welcome you to add those :).