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

Function test_extract_struct

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

Source from the content-addressed store, hash-verified

734
735 #[test]
736 fn test_extract_struct() {
737 let mut parser = SwiftParser::new();
738 let source = r#"
739struct Point {
740 var x: Double
741 var y: Double
742
743 func distance(to other: Point) -> Double {
744 let dx = x - other.x
745 let dy = y - other.y
746 return (dx * dx + dy * dy).squareRoot()
747 }
748}
749"#;
750 let entities = parser.extract(source, "geometry.swift");
751
752 let point = entities
753 .iter()
754 .find(|e| e.name == "Point")
755 .expect("Should find Point");
756 assert_eq!(point.kind, EntityKind::Class); // Structs map to Class
757 assert!(
758 point.signature.as_ref().unwrap().contains("struct Point"),
759 "Signature should say 'struct': {:?}",
760 point.signature
761 );
762
763 let distance = entities.iter().find(|e| e.name == "distance");
764 assert!(distance.is_some(), "Should find distance method");
765 assert_eq!(distance.unwrap().kind, EntityKind::Method);
766 }
767
768 #[test]
769 fn test_extract_enum() {

Callers

nothing calls this directly

Calls 2

extractMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected