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

Function test_extract_method

atomic-semantic/src/parsers/go.rs:517–544  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

515
516 #[test]
517 fn test_extract_method() {
518 let mut parser = GoParser::new();
519 let source = r#"
520package main
521
522func (u *User) FullName() string {
523 return u.Name
524}
525
526func (u *User) setAge(age int) {
527 u.Age = age
528}
529"#;
530 let entities = parser.extract(source, "user.go");
531
532 let full_name = entities.iter().find(|e| e.name == "FullName").unwrap();
533 assert_eq!(full_name.kind, EntityKind::Method);
534 assert!(full_name.exported);
535 assert!(
536 full_name.signature.as_ref().unwrap().contains("*User"),
537 "Method signature should include receiver: {:?}",
538 full_name.signature
539 );
540
541 let set_age = entities.iter().find(|e| e.name == "setAge").unwrap();
542 assert_eq!(set_age.kind, EntityKind::Method);
543 assert!(!set_age.exported, "lowercase method should not be exported");
544 }
545
546 #[test]
547 fn test_extract_type_alias() {

Callers

nothing calls this directly

Calls 3

extractMethod · 0.45
unwrapMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected