| 679 | |
| 680 | #[test] |
| 681 | fn test_extract_async_function() { |
| 682 | let mut parser = RustParser::new(); |
| 683 | let source = r#" |
| 684 | pub async fn fetch_data(url: &str) -> Result<String, Error> { |
| 685 | Ok("data".to_string()) |
| 686 | } |
| 687 | "#; |
| 688 | let entities = parser.extract(source, "src/client.rs"); |
| 689 | let fetch = entities.iter().find(|e| e.name == "fetch_data").unwrap(); |
| 690 | assert_eq!(fetch.kind, EntityKind::Function); |
| 691 | assert!(fetch.exported); |
| 692 | // Note: whether "async" appears in the signature depends on tree-sitter's |
| 693 | // Rust grammar version. The function should be found regardless. |
| 694 | assert!( |
| 695 | fetch.signature.as_ref().unwrap().contains("fetch_data"), |
| 696 | "Signature should contain function name: {:?}", |
| 697 | fetch.signature |
| 698 | ); |
| 699 | } |
| 700 | |
| 701 | #[test] |
| 702 | fn test_extract_struct() { |