forked from hydro-project/hydroflow
-
Notifications
You must be signed in to change notification settings - Fork 0
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 (hydro-project#898)
- Loading branch information
1 parent
55869f6
commit 9786d60
Showing
18 changed files
with
533 additions
and
52 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,48 @@ | ||
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; | ||
|
||
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
2 changes: 1 addition & 1 deletion
2
hydroflow/tests/compile-fail/surface_syntax_eol_indexing.stderr
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
2 changes: 1 addition & 1 deletion
2
hydroflow/tests/compile-fail/surface_syntax_eol_missingop.stderr
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
2 changes: 1 addition & 1 deletion
2
hydroflow/tests/compile-fail/surface_syntax_indexing_empty.stderr
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
2 changes: 1 addition & 1 deletion
2
hydroflow/tests/compile-fail/surface_syntax_paren_indexing.stderr
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
2 changes: 1 addition & 1 deletion
2
hydroflow/tests/compile-fail/surface_syntax_paren_missingop.stderr
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.