@@ -897,8 +897,27 @@ impl Display for SubprogramDefault {
897897
898898impl Display for InterfacePackageDeclaration {
899899 fn fmt ( & self , f : & mut Formatter < ' _ > ) -> Result {
900- // Not used: generic_map
901- write ! ( f, "package {} is new {}" , self . ident, self . package_name)
900+ write ! (
901+ f,
902+ "package {} is new {}\n generic map (" ,
903+ self . ident, self . package_name
904+ ) ?;
905+ match & self . generic_map {
906+ InterfacePackageGenericMapAspect :: Map ( assoc_list) => {
907+ let mut first = true ;
908+ for assoc in assoc_list {
909+ if first {
910+ write ! ( f, "\n {}" , assoc) ?;
911+ } else {
912+ write ! ( f, ",\n {}" , assoc) ?;
913+ }
914+ first = false ;
915+ }
916+ write ! ( f, "\n )" )
917+ }
918+ InterfacePackageGenericMapAspect :: Box => write ! ( f, "<>)" ) ,
919+ InterfacePackageGenericMapAspect :: Default => write ! ( f, "default)" ) ,
920+ }
902921 }
903922}
904923
@@ -986,8 +1005,23 @@ impl Display for ContextDeclaration {
9861005
9871006impl Display for PackageInstantiation {
9881007 fn fmt ( & self , f : & mut Formatter < ' _ > ) -> Result {
989- // Not used: context_clause, generic_map
990- write ! ( f, "package {} is new {};" , self . ident, self . package_name)
1008+ // Not used: context_clause
1009+ write ! ( f, "package {} is new {}" , self . ident, self . package_name) ?;
1010+ if let Some ( assoc_list) = & self . generic_map {
1011+ let mut first = true ;
1012+ for assoc in assoc_list {
1013+ if first {
1014+ write ! ( f, "\n generic map (\n {}" , assoc) ?;
1015+ } else {
1016+ write ! ( f, ",\n {}" , assoc) ?;
1017+ }
1018+ first = false ;
1019+ }
1020+ if !first {
1021+ write ! ( f, "\n )" ) ?;
1022+ }
1023+ }
1024+ write ! ( f, ";" )
9911025 }
9921026}
9931027
@@ -1840,11 +1874,30 @@ end units;",
18401874 }
18411875
18421876 #[ test]
1843- fn test_interface_declaration_package ( ) {
1844- assert_format_eq (
1877+ fn test_interface_declaration_package_map ( ) {
1878+ assert_format (
18451879 "package foo is new lib.pkg
1846- generic map (foo => bar)" ,
1847- "package foo is new lib.pkg" ,
1880+ generic map (
1881+ foo => bar
1882+ )" ,
1883+ Code :: parameter,
1884+ ) ;
1885+ }
1886+
1887+ #[ test]
1888+ fn test_interface_declaration_package_box ( ) {
1889+ assert_format (
1890+ "package foo is new lib.pkg
1891+ generic map (<>)" ,
1892+ Code :: parameter,
1893+ ) ;
1894+ }
1895+
1896+ #[ test]
1897+ fn test_interface_declaration_package_default ( ) {
1898+ assert_format (
1899+ "package foo is new lib.pkg
1900+ generic map (default)" ,
18481901 Code :: parameter,
18491902 ) ;
18501903 }
@@ -2012,6 +2065,23 @@ end context;",
20122065 } ) ;
20132066 }
20142067
2068+ #[ test]
2069+ fn test_package_instantiation_generic_map ( ) {
2070+ assert_format (
2071+ "package ident is new lib.foo.bar
2072+ generic map (
2073+ foo => bar,
2074+ baz => qux
2075+ );" ,
2076+ |code| {
2077+ assert_matches ! (
2078+ code. design_file( ) . design_units. remove( 0 ) ,
2079+ AnyDesignUnit :: Primary ( AnyPrimaryUnit :: PackageInstance ( instance) ) => instance
2080+ )
2081+ } ,
2082+ ) ;
2083+ }
2084+
20152085 #[ test]
20162086 fn test_configuration_declaration ( ) {
20172087 assert_format_eq (
0 commit comments