use super::*;
#[test]
fn package_name_must_be_visible_in_package_instance() {
let mut builder = LibraryBuilder::new();
let code = builder.code(
"libname",
"
package gpkg is
generic (const : natural);
end package;
package ipkg_err is new gpkg generic map (const => 0);
package ipkg_ok is new work.gpkg generic map (const => 0);
package nested is
package ipkg_err is new gpkg generic map (const => 0);
package ipkg_ok is new work.gpkg generic map (const => 0);
end package;
",
);
let diagnostics = builder.analyze();
check_diagnostics(
diagnostics,
vec![
Diagnostic::error(code.s("gpkg", 2), "No declaration of 'gpkg'"),
Diagnostic::error(code.s("gpkg", 4), "No declaration of 'gpkg'"),
],
);
}
#[test]
fn package_name_must_be_an_uninstantiated_package_in_package_instance() {
let mut builder = LibraryBuilder::new();
let code = builder.code(
"libname",
"
package pkg is
constant const : natural := 0;
end package;
package ipkg is new work.pkg generic map (const => 0);
package nested is
package ipkg2 is new work.pkg.const generic map (const => 0);
end package;
",
);
let diagnostics = builder.analyze();
check_diagnostics(
diagnostics,
vec![
Diagnostic::error(
code.s1("work.pkg"),
"'work.pkg' is not an uninstantiated generic package",
),
Diagnostic::error(
code.s1("work.pkg.const"),
"'work.pkg.const' is not an uninstantiated generic package",
),
],
);
}