| 1488 | #[test] |
| 1489 | #[cfg(any(unix, windows))] |
| 1490 | fn no_stack_overflow_on_drop() { |
| 1491 | use std::thread; |
| 1492 | |
| 1493 | let run = || { |
| 1494 | let span = || Span::splat(Position::new(0, 0, 0)); |
| 1495 | let mut ast = Ast::Empty(span()); |
| 1496 | for i in 0..200 { |
| 1497 | ast = Ast::Group(Group { |
| 1498 | span: span(), |
| 1499 | kind: GroupKind::CaptureIndex(i), |
| 1500 | ast: Box::new(ast), |
| 1501 | }); |
| 1502 | } |
| 1503 | assert!(!ast.is_empty()); |
| 1504 | }; |
| 1505 | |
| 1506 | // We run our test on a thread with a small stack size so we can |
| 1507 | // force the issue more easily. |
| 1508 | thread::Builder::new() |
| 1509 | .stack_size(1<<10) |
| 1510 | .spawn(run) |
| 1511 | .unwrap() |
| 1512 | .join() |
| 1513 | .unwrap(); |
| 1514 | } |
| 1515 | } |