I also wonder if the knowledge of the speaker plays a part:
On Monday, the teacher said that there would be a test on Wednesday. On Tuesday, the teacher said that the Wednesday test was cancelled. So, I didn't have to revise on Tuesday night. (a fact)
(As David mentioned above: We didn't/don't have a test today, so there was no need for me to prepare/review for it last night.)
On Monday, the teacher said that there would be a test on Wednesday. I studied/revised Tuesday evening. On Wednesday, I arrived and the teacher was absent and the test was cancelled. So, I had studied/revised for no reason. I could have watched TV instead. I needn't have revised. (A slight feeling of annoyance for having wasted my time!)
The test example Ahmed provided ends with an exclamation point, which is why I think the author of the test suggested needn't have revised as the answer. The respondent was a bit annoyed.