Write a Python function merge_intervals(intervals) that merges overlapping [start, end] pairs, with a docstring and three doctests. Code only.
