| 515 | |
| 516 | #[test] |
| 517 | fn test_extract_method() { |
| 518 | let mut parser = GoParser::new(); |
| 519 | let source = r#" |
| 520 | package main |
| 521 | |
| 522 | func (u *User) FullName() string { |
| 523 | return u.Name |
| 524 | } |
| 525 | |
| 526 | func (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() { |