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

Function test_multiple_entities

atomic-semantic/src/parsers/python.rs:698–724  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

696
697 #[test]
698 fn test_multiple_entities() {
699 let mut parser = PythonParser::new();
700 let source = r#"
701MAX_SIZE = 100
702
703def validate(data: dict) -> bool:
704 return len(data) > 0
705
706class Validator:
707 def __init__(self):
708 self.rules = []
709
710 def add_rule(self, rule):
711 self.rules.append(rule)
712
713 def validate(self, data):
714 return all(r(data) for r in self.rules)
715"#;
716 let entities = parser.extract(source, "validation.py");
717
718 let names: Vec<&str> = entities.iter().map(|e| e.name.as_str()).collect();
719 assert!(names.contains(&"MAX_SIZE"), "Should find MAX_SIZE");
720 assert!(names.contains(&"validate"), "Should find validate function");
721 assert!(names.contains(&"Validator"), "Should find Validator class");
722 assert!(names.contains(&"__init__"), "Should find __init__ method");
723 assert!(names.contains(&"add_rule"), "Should find add_rule method");
724 }
725
726 #[test]
727 fn test_language() {

Callers

nothing calls this directly

Calls 4

extractMethod · 0.45
collectMethod · 0.45
iterMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected