Skip to content

Commit

Permalink
chore: add test case showing reexports (#4001)
Browse files Browse the repository at this point in the history
# Description

## Problem\*

Resolves <!-- Link to GitHub Issue -->

## Summary\*

This PR adds a test case to just show the current state of reexports
across libraries.

## Additional Context



## Documentation\*

Check one:
- [x] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[Exceptional Case]** Documentation to be submitted in a separate
PR.

# PR Checklist\*

- [x] I have tested the changes locally.
- [x] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
  • Loading branch information
TomAFrench committed Jan 10, 2024
1 parent cc3c2c2 commit b003f0a
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions compiler/noirc_frontend/src/hir/def_map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ pub struct CrateDefMap {

pub(crate) krate: CrateId,

/// Maps an external dependency's name to its root module id.
pub(crate) extern_prelude: BTreeMap<String, ModuleId>,
}

Expand Down
7 changes: 7 additions & 0 deletions test_programs/compile_success_empty/reexports/Nargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "reexports"
type = "bin"
authors = [""]

[dependencies]
reexporting_lib = { path = "../../test_libraries/reexporting_lib" }
8 changes: 8 additions & 0 deletions test_programs/compile_success_empty/reexports/src/main.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use dep::reexporting_lib::{FooStruct, MyStruct, lib};

fn main() {
let x: FooStruct = MyStruct {
inner: 0
};
assert(lib::is_struct_zero(x));
}
6 changes: 6 additions & 0 deletions test_programs/test_libraries/exporting_lib/Nargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "exporting_lib"
type = "lib"
authors = [""]

[dependencies]
10 changes: 10 additions & 0 deletions test_programs/test_libraries/exporting_lib/src/lib.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

struct MyStruct {
inner: Field
}

type FooStruct = MyStruct;

fn is_struct_zero(val: MyStruct) -> bool {
val.inner == 0
}
7 changes: 7 additions & 0 deletions test_programs/test_libraries/reexporting_lib/Nargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "reexporting_lib"
type = "lib"
authors = [""]

[dependencies]
exporting_lib = { path = "../exporting_lib" }
3 changes: 3 additions & 0 deletions test_programs/test_libraries/reexporting_lib/src/lib.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
use dep::exporting_lib::{MyStruct, FooStruct};

use dep::exporting_lib as lib;

0 comments on commit b003f0a

Please sign in to comment.