Skip to content

Commit

Permalink
add 'module_access_aliased' test to nix
Browse files Browse the repository at this point in the history
  • Loading branch information
PgBiel committed Jun 8, 2024
1 parent b479101 commit 0c2560a
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
26 changes: 26 additions & 0 deletions compiler-core/src/nix/tests/case_clause_guards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,32 @@ fn module_access_submodule() {
);
}

#[test]
fn module_access_aliased() {
assert_nix!(
(
"package",
"hero/submodule",
r#"
pub type Hero {
Hero(name: String)
}
pub const ironman = Hero("Tony Stark")
"#
),
r#"
import hero/submodule as myhero
pub fn main() {
let name = "Tony Stark"
case name {
n if n == myhero.ironman.name -> True
_ -> False
}
}
"#
);
}

#[test]
fn module_nested_access() {
assert_nix!(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
source: compiler-core/src/nix/tests/case_clause_guards.rs
expression: "\n import hero/submodule as myhero\n pub fn main() {\n let name = \"Tony Stark\"\n case name {\n n if n == myhero.ironman.name -> True\n _ -> False\n }\n }\n "
---
let
myhero' = builtins.import ./../../package/hero/submodule.nix;

main =
{ }:
let
name = "Tony Stark";
in
if name == myhero'.ironman.name then let n = name; in true
else false;
in
{ inherit main; }

0 comments on commit 0c2560a

Please sign in to comment.