The problem with a programming test is that it usually becomes an exercise in does the
Person doing the test write code in the same way as the
Person setting the test.
With an added twist of did the person taking the test understand the unspecified parts of the test!
Here I am looking at a short test, something that might take 20-30 minutes and is done on the employer's site before or after an interview rather than one that takes 2-10 hours and is done at home.
Recently I was talking to a recruitment agency who mentioned that they had sent multiple candidates to an employer and they had all failed a programming test and all for the same reason.
They had answered the question asked in a sensible way but the company wanted it answered in an unreasonably complex way that might have been reasonable in the real world.