-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(modules): add import!() expression
- Loading branch information
Showing
11 changed files
with
472 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
use std::cell::RefCell; | ||
use std::rc::Rc; | ||
|
||
use hydroflow::hydroflow_syntax; | ||
use hydroflow::scheduled::graph::Hydroflow; | ||
use hydroflow::util::multiset::HashMultiSet; | ||
|
||
pub fn main() { | ||
let output = Rc::new(RefCell::new( | ||
HashMultiSet::<(usize, usize, usize)>::default(), | ||
)); | ||
|
||
let mut df: Hydroflow = { | ||
let output = output.clone(); | ||
hydroflow_syntax! { | ||
source_iter(0..2) -> [0]cj; | ||
source_iter(0..2) -> [1]cj; | ||
source_iter(0..2) -> [2]cj; | ||
|
||
source_iter(0..5) -> mod; | ||
Check failure on line 20 in hydroflow/examples/modules/main.rs GitHub Actions / Check (pinned-nightly)
Check failure on line 20 in hydroflow/examples/modules/main.rs GitHub Actions / Check (pinned-nightly)
Check failure on line 20 in hydroflow/examples/modules/main.rs GitHub Actions / Test Suite (pinned-nightly)
|
||
|
||
cj = import!("triple_cross_join.hf") | ||
-> for_each(|x| output.borrow_mut().insert(x)); | ||
} | ||
}; | ||
|
||
println!("{}", df.meta_graph().unwrap().to_mermaid()); | ||
|
||
df.run_available(); | ||
|
||
#[rustfmt::skip] | ||
assert_eq!( | ||
*output.borrow(), | ||
HashMultiSet::from_iter([ | ||
(0, 0, 0), | ||
(0, 0, 1), | ||
(0, 1, 0), | ||
(0, 1, 1), | ||
(1, 0, 0), | ||
(1, 0, 1), | ||
(1, 1, 0), | ||
(1, 1, 1), | ||
]) | ||
); | ||
} | ||
|
||
#[test] | ||
fn test() { | ||
main(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
mod[0] | ||
-> [0]cj1; | ||
|
||
mod[1] | ||
-> [1]cj1; | ||
|
||
cj1 = cross_join() | ||
-> [0]cj2; | ||
|
||
mod[2] | ||
-> [1]cj2; | ||
|
||
cj2 = cross_join() | ||
-> map(|((a, b), c)| (a, b, c)) | ||
-> mod; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.