-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(hydroflow_lang): allow
demux_enum
to have any number of outputs,
- Loading branch information
1 parent
fa41720
commit 9e5f58e
Showing
15 changed files
with
335 additions
and
98 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
18 changes: 18 additions & 0 deletions
18
hydroflow/tests/compile-fail/surface_demuxenum_port_duplicate_one.rs
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,18 @@ | ||
use hydroflow::hydroflow_syntax; | ||
use hydroflow::util::demux_enum::DemuxEnum; | ||
|
||
fn main() { | ||
#[derive(DemuxEnum)] | ||
enum Shape { | ||
Square(f64), | ||
} | ||
|
||
let mut df = hydroflow_syntax! { | ||
my_demux = source_iter([ | ||
Shape::Square(9.0), | ||
]) -> demux_enum::<Shape>(); | ||
my_demux[Square] -> for_each(std::mem::drop); | ||
my_demux[Square] -> for_each(std::mem::drop); | ||
}; | ||
df.run_available(); | ||
} |
11 changes: 11 additions & 0 deletions
11
hydroflow/tests/compile-fail/surface_demuxenum_port_duplicate_one.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
error: Output connection conflicts with below ($DIR/tests/compile-fail/surface_demuxenum_port_duplicate_one.rs:15:18) (1/2) | ||
--> tests/compile-fail/surface_demuxenum_port_duplicate_one.rs:14:18 | ||
| | ||
14 | my_demux[Square] -> for_each(std::mem::drop); | ||
| ^^^^^^ | ||
|
||
error: Output connection conflicts with above ($DIR/tests/compile-fail/surface_demuxenum_port_duplicate_one.rs:14:18) (2/2) | ||
--> tests/compile-fail/surface_demuxenum_port_duplicate_one.rs:15:18 | ||
| | ||
15 | my_demux[Square] -> for_each(std::mem::drop); | ||
| ^^^^^^ |
14 changes: 14 additions & 0 deletions
14
hydroflow/tests/compile-fail/surface_demuxenum_port_extra_zero.rs
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,14 @@ | ||
use hydroflow::util::demux_enum::DemuxEnum; | ||
use hydroflow::hydroflow_syntax; | ||
|
||
fn main() { | ||
#[derive(DemuxEnum)] | ||
enum Shape { | ||
} | ||
|
||
let mut df = hydroflow_syntax! { | ||
my_demux = source_iter([]) -> demux_enum::<Shape>(); | ||
my_demux[Square] -> for_each(std::mem::drop); | ||
}; | ||
df.run_available(); | ||
} |
37 changes: 37 additions & 0 deletions
37
hydroflow/tests/compile-fail/surface_demuxenum_port_extra_zero.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
error[E0599]: no variant named `Square` found for enum `Shape` | ||
--> tests/compile-fail/surface_demuxenum_port_extra_zero.rs:11:18 | ||
| | ||
6 | enum Shape { | ||
| ---------- variant `Square` not found here | ||
... | ||
11 | my_demux[Square] -> for_each(std::mem::drop); | ||
| ^^^^^^ variant not found in `Shape` | ||
|
||
error[E0277]: the trait bound `Shape: SingleVariant` is not satisfied | ||
--> tests/compile-fail/surface_demuxenum_port_extra_zero.rs:10:52 | ||
| | ||
10 | my_demux = source_iter([]) -> demux_enum::<Shape>(); | ||
| ^^^^^ the trait `SingleVariant` is not implemented for `Shape` | ||
| | ||
= note: requires that the enum have only one variant. | ||
= note: ensure there are no missing outputs; there must be exactly one output for each enum variant. | ||
|
||
error[E0277]: the trait bound `Shape: SingleVariant` is not satisfied | ||
--> tests/compile-fail/surface_demuxenum_port_extra_zero.rs:10:39 | ||
| | ||
10 | my_demux = source_iter([]) -> demux_enum::<Shape>(); | ||
| ^^^^^^^^^^^^^^^^^^^^^ the trait `SingleVariant` is not implemented for `Shape` | ||
| | ||
= note: requires that the enum have only one variant. | ||
= note: ensure there are no missing outputs; there must be exactly one output for each enum variant. | ||
|
||
error[E0277]: the trait bound `Shape: SingleVariant` is not satisfied | ||
--> tests/compile-fail/surface_demuxenum_port_extra_zero.rs:10:39 | ||
| | ||
10 | my_demux = source_iter([]) -> demux_enum::<Shape>(); | ||
| _______________________________________^ | ||
11 | | my_demux[Square] -> for_each(std::mem::drop); | ||
| |____________________________________________________^ the trait `SingleVariant` is not implemented for `Shape` | ||
| | ||
= note: requires that the enum have only one variant. | ||
= note: ensure there are no missing outputs; there must be exactly one output for each enum variant. |
19 changes: 19 additions & 0 deletions
19
hydroflow/tests/compile-fail/surface_demuxenum_port_missing_one.rs
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,19 @@ | ||
use hydroflow::util::demux_enum::DemuxEnum; | ||
use hydroflow::hydroflow_syntax; | ||
|
||
fn main() { | ||
#[derive(DemuxEnum)] | ||
enum Shape { | ||
Square(f64), | ||
Rectangle { w: f64, h: f64 }, | ||
} | ||
|
||
let mut df = hydroflow_syntax! { | ||
my_demux = source_iter([ | ||
Shape::Rectangle { w: 10.0, h: 8.0 }, | ||
Shape::Square(9.0), | ||
]) -> demux_enum::<Shape>(); | ||
my_demux[Rectangle] -> for_each(std::mem::drop); | ||
}; | ||
df.run_available(); | ||
} |
28 changes: 28 additions & 0 deletions
28
hydroflow/tests/compile-fail/surface_demuxenum_port_missing_one.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
error[E0277]: the trait bound `Shape: SingleVariant` is not satisfied | ||
--> tests/compile-fail/surface_demuxenum_port_missing_one.rs:15:28 | ||
| | ||
15 | ]) -> demux_enum::<Shape>(); | ||
| ^^^^^ the trait `SingleVariant` is not implemented for `Shape` | ||
| | ||
= note: requires that the enum have only one variant. | ||
= note: ensure there are no missing outputs; there must be exactly one output for each enum variant. | ||
|
||
error[E0277]: the trait bound `Shape: SingleVariant` is not satisfied | ||
--> tests/compile-fail/surface_demuxenum_port_missing_one.rs:15:15 | ||
| | ||
15 | ]) -> demux_enum::<Shape>(); | ||
| ^^^^^^^^^^^^^^^^^^^^^ the trait `SingleVariant` is not implemented for `Shape` | ||
| | ||
= note: requires that the enum have only one variant. | ||
= note: ensure there are no missing outputs; there must be exactly one output for each enum variant. | ||
|
||
error[E0277]: the trait bound `Shape: SingleVariant` is not satisfied | ||
--> tests/compile-fail/surface_demuxenum_port_missing_one.rs:15:15 | ||
| | ||
15 | ]) -> demux_enum::<Shape>(); | ||
| _______________^ | ||
16 | | my_demux[Rectangle] -> for_each(std::mem::drop); | ||
| |_______________________________________________________^ the trait `SingleVariant` is not implemented for `Shape` | ||
| | ||
= note: requires that the enum have only one variant. | ||
= note: ensure there are no missing outputs; there must be exactly one output for each enum variant. |
17 changes: 17 additions & 0 deletions
17
hydroflow/tests/compile-fail/surface_demuxenum_port_wrong_one.rs
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,17 @@ | ||
use hydroflow::util::demux_enum::DemuxEnum; | ||
use hydroflow::hydroflow_syntax; | ||
|
||
fn main() { | ||
#[derive(DemuxEnum)] | ||
enum Shape { | ||
Square(f64), | ||
} | ||
|
||
let mut df = hydroflow_syntax! { | ||
my_demux = source_iter([ | ||
Shape::Square(9.0), | ||
]) -> demux_enum::<Shape>(); | ||
my_demux[Circle] -> for_each(std::mem::drop); | ||
}; | ||
df.run_available(); | ||
} |
8 changes: 8 additions & 0 deletions
8
hydroflow/tests/compile-fail/surface_demuxenum_port_wrong_one.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
error[E0599]: no variant named `Circle` found for enum `Shape` | ||
--> tests/compile-fail/surface_demuxenum_port_wrong_one.rs:14:18 | ||
| | ||
6 | enum Shape { | ||
| ---------- variant `Circle` not found here | ||
... | ||
14 | my_demux[Circle] -> for_each(std::mem::drop); | ||
| ^^^^^^ variant not found in `Shape` |
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.