use crate::protocol::*; use crate::protocol::eval::*; use crate::runtime2::runtime::*; use crate::runtime2::component::CompPDL; #[test] fn test_component_creation() { let pd = ProtocolDescription::parse(b" primitive nothing_at_all() { s32 a = 5; auto b = 5 + a; } ").expect("compilation"); let rt = Runtime::new(1, pd); for i in 0..20 { let prompt = rt.inner.protocol.new_component(b"", b"nothing_at_all", ValueGroup::new_stack(Vec::new())) .expect("component creation"); let comp = CompPDL::new(prompt, 0); let (key, _) = rt.inner.create_pdl_component(comp, false); rt.inner.enqueue_work(key); } } #[test] fn test_component_communication() { let pd = ProtocolDescription::parse(b" primitive sender(out o) { print(\"sender\"); sync put(o, 1); } primitive receiver(in i) { print(\"receiver\"); sync get(i); } composite constructor() { channel o -> i; print(\"creating sender\"); new sender(o); print(\"creating receiver\"); new receiver(i); print(\"done\"); } ").expect("compilation"); let rt = Runtime::new(1, pd); let prompt = rt.inner.protocol.new_component(b"", b"constructor", ValueGroup::new_stack(Vec::new())) .expect("creation"); let (key, _) = rt.inner.create_pdl_component(CompPDL::new(prompt, 0), false); rt.inner.enqueue_work(key); }