Testcase and expected output for #3099

As requested; a testcase for the fix in pullrequest #3100.
Originally committed to wrong branch.