Add stack depth tests. References #2035.