| 656 | |
| 657 | #[test] |
| 658 | fn test_extract_async_function() { |
| 659 | let mut parser = RustParser::new(); |
| 660 | let source = r#" |
| 661 | pub async fn fetch_data(url: &str) -> Result<String, Error> { |
| 662 | Ok("data".to_string()) |
| 663 | } |
| 664 | "#; |
| 665 | let entities = parser.extract(source, "src/client.rs"); |
| 666 | let fetch = entities.iter().find(|e| e.name == "fetch_data").unwrap(); |
| 667 | assert_eq!(fetch.kind, EntityKind::Function); |
| 668 | assert!(fetch.exported); |
| 669 | // Note: whether "async" appears in the signature depends on tree-sitter's |
| 670 | // Rust grammar version. The function should be found regardless. |
| 671 | assert!( |
| 672 | fetch.signature.as_ref().unwrap().contains("fetch_data"), |
| 673 | "Signature should contain function name: {:?}", |
| 674 | fetch.signature |
| 675 | ); |
| 676 | } |
| 677 | |
| 678 | #[test] |
| 679 | fn test_extract_struct() { |