| 653 | |
| 654 | #[test] |
| 655 | fn test_line_numbers() { |
| 656 | let mut parser = PythonParser::new(); |
| 657 | let source = r#" |
| 658 | def first(): |
| 659 | pass |
| 660 | |
| 661 | def second(): |
| 662 | pass |
| 663 | "#; |
| 664 | let entities = parser.extract(source, "lines.py"); |
| 665 | let first = entities.iter().find(|e| e.name == "first").unwrap(); |
| 666 | let second = entities.iter().find(|e| e.name == "second").unwrap(); |
| 667 | assert!(first.line < second.line, "first should be before second"); |
| 668 | assert!( |
| 669 | first.end_line < second.line, |
| 670 | "first should end before second starts" |
| 671 | ); |
| 672 | } |
| 673 | |
| 674 | #[test] |
| 675 | fn test_multiple_entities() { |