# Keep nested package bindings and mutable state across separate REPL submissions.
let $fixture = $args[0]
mkdir -p "${fixture}/tools/package"
printf "%s" 'pub let $value = 7; pub fn read(): Integer { $value }; pub struct Box { pub n: Integer }; pub fn Box::read(): Integer { $self.n }' -> "${fixture}/tools/package/leaf.shy"
printf "%s" 'pub import leaf::{ $value, read, Box }; echo package-once' -> "${fixture}/tools/package/init.shy"
check_repl ["id": "NESTED-IMPORT-REPL", "name": "Nested package imports",
"steps": [
['import tools::package::{ $value, read, Box }', "output", "package-once"],
['echo (read) Box(n: 2).read', "output", "7 2"],
['$value = 9', "quiet", ""],
['import tools::package; import tools::package', "quiet", ""],
['import tools::package::init', "error", "init.shy is a module entry point"],
['echo $tools::package::value (tools::package::read)', "output", "9 9"],
['import tools::package::missing', "error", "was not found"],
['echo (read) $tools::package::value', "output", "9 9"],
['printf "%s" \'pub fn read(): Integer { 99 }\' -> "tools/package.shy"', "quiet", ""],
['import tools::package', "error", "Ambiguous module"],
['echo (read)', "output", "9"],
['rm "tools/package.shy"', "quiet", ""],
['import tools::package', "quiet", ""],
['import absent::nested when false; echo ok', "output", "ok"]
], "exit": 0]