Brandon Beresini sent me a patch yesterday adding tests for JOIN under various circumstances, which I believe he worked on with Bryan Caldwell and Ali Shemiran. I made a few modifications; the result is below.