MCPcopy Create free account
hub / github.com/MegEngine/MegFlow / test_empty

Function test_empty

flow-rs/tests/01-subgraph.rs:93–136  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

91
92#[rt::test]
93async fn test_empty() -> Result<()> {
94 let mut graph = Builder::default()
95 .template(
96 r#"
97main="test"
98nodes=[{name="gb",ty="BinaryOpr"}]
99[[graphs]]
100name="sub"
101inputs=[
102 {name="a",cap=1,ports=["gb:a"]},
103 {name="b",cap=1,ports=["gb:b"]}
104]
105outputs=[{name="c",cap=1,ports=["gb:c"]}]
106[[graphs]]
107name="test"
108inputs=[{name="inp",cap=1,ports=["t1:inp","t2:inp"]}]
109outputs=[{name="out",cap=2,ports=["t3:out"]}]
110connections=[
111 {cap=1,ports=["t1:out", "sub:a"]},
112 {cap=1,ports=["t2:out", "sub:b"]},
113 {cap=1,ports=["t3:inp", "sub:c"]}
114]
115nodes=[
116 {name="sub",ty="sub"},
117 {name="t1",ty="Transform"},
118 {name="t2",ty="Transform"},
119 {name="t3",ty="Transform"}
120]
121 "#
122 .to_owned(),
123 )
124 .build()?;
125 let inp = graph.input("inp").unwrap();
126 let out = graph.output("out").unwrap();
127 let handle = graph.start();
128
129 inp.send(Envelope::new(1usize)).await.ok();
130 inp.close();
131 assert!(out.recv::<usize>().await.is_ok());
132 assert!(out.recv::<usize>().await.is_ok());
133 assert!(out.recv::<usize>().await.is_err());
134 handle.await?;
135 Ok(())
136}

Callers

nothing calls this directly

Calls 7

templateMethod · 0.80
buildMethod · 0.45
inputMethod · 0.45
outputMethod · 0.45
startMethod · 0.45
sendMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected