MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / test_extract_async_function

Function test_extract_async_function

atomic-semantic/src/parsers/rust.rs:681–699  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

679
680 #[test]
681 fn test_extract_async_function() {
682 let mut parser = RustParser::new();
683 let source = r#"
684pub 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() {

Callers

nothing calls this directly

Calls 3

extractMethod · 0.45
unwrapMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected