Test case for end and next.