| 58 | |
| 59 | #[test] |
| 60 | fn test_rust_async_function() { |
| 61 | let source = r#" |
| 62 | pub async fn fetch_data() -> String { |
| 63 | String::new() |
| 64 | } |
| 65 | "#; |
| 66 | let extractor = RustExtractor; |
| 67 | let result = extractor.extract("async.rs", source); |
| 68 | assert!(result.errors.is_empty(), "errors: {:?}", result.errors); |
| 69 | let fns: Vec<_> = result |
| 70 | .nodes |
| 71 | .iter() |
| 72 | .filter(|n| n.kind == NodeKind::Function) |
| 73 | .collect(); |
| 74 | assert_eq!(fns.len(), 1); |
| 75 | assert!(fns[0].is_async, "expected async function"); |
| 76 | } |
| 77 | |
| 78 | #[test] |
| 79 | fn test_rust_struct_and_fields() { |