Add regression test for #14244.

Have confirmed that the test fails if #14244 is reverted.
CC: @programcsharp