We’ve known for a long time that sleep improves learning. I remember hearing about studies decades ago that examined the impact of sleep sessions between learning sessions. Essentially sleep was shown to help consolidate learning, and sleep was found to be more helpful between study sessions than any other activity, including more studying!
What we may not realize is that not only is sleep helpful, it’s truly necessary to good learning. Without enough sleep we can’t remember things we have learned before or after that sleep period.
So if you pull an all-nighter, you won’t keep much of that information in your long-term memory, even if you do pass the test.