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

Function test_extract_class

atomic-semantic/src/parsers/swift.rs:695–733  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

693
694 #[test]
695 fn test_extract_class() {
696 let mut parser = SwiftParser::new();
697 let source = r#"
698class UserService {
699 func getUser(id: String) -> String {
700 return id
701 }
702
703 func createUser(name: String) -> String {
704 return name
705 }
706}
707"#;
708 let entities = parser.extract(source, "service.swift");
709
710 let service = entities
711 .iter()
712 .find(|e| e.name == "UserService")
713 .expect("Should find UserService");
714 assert_eq!(service.kind, EntityKind::Class);
715 assert!(service.exported);
716 assert!(
717 service
718 .signature
719 .as_ref()
720 .unwrap()
721 .contains("class UserService"),
722 "Signature: {:?}",
723 service.signature
724 );
725
726 let get_user = entities.iter().find(|e| e.name == "getUser");
727 assert!(get_user.is_some(), "Should find getUser method");
728 assert_eq!(get_user.unwrap().kind, EntityKind::Method);
729
730 let create_user = entities.iter().find(|e| e.name == "createUser");
731 assert!(create_user.is_some(), "Should find createUser method");
732 assert_eq!(create_user.unwrap().kind, EntityKind::Method);
733 }
734
735 #[test]
736 fn test_extract_struct() {

Callers

nothing calls this directly

Calls 2

extractMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected