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

Function test_extract_protocol

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

Source from the content-addressed store, hash-verified

792
793 #[test]
794 fn test_extract_protocol() {
795 let mut parser = SwiftParser::new();
796 let source = r#"
797protocol Drawable {
798 func draw()
799 var color: String { get }
800}
801"#;
802 let entities = parser.extract(source, "protocols.swift");
803 let drawable = entities
804 .iter()
805 .find(|e| e.name == "Drawable")
806 .expect("Should find Drawable");
807 assert_eq!(drawable.kind, EntityKind::Interface);
808 assert!(drawable.exported);
809 assert!(
810 drawable
811 .signature
812 .as_ref()
813 .unwrap()
814 .contains("protocol Drawable"),
815 "Signature: {:?}",
816 drawable.signature
817 );
818
819 // Protocol methods should be extracted as Method
820 let draw = entities.iter().find(|e| e.name == "draw");
821 assert!(draw.is_some(), "Should find draw method in protocol");
822 assert_eq!(draw.unwrap().kind, EntityKind::Method);
823 }
824
825 #[test]
826 fn test_extract_import() {

Callers

nothing calls this directly

Calls 2

extractMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected