diff --git a/src/runtime2/tests/mod.rs b/src/runtime2/tests/mod.rs index 0225f944d0c23c4aa5eaf7e55a26939ebd204bc9..d8e4a4011bb4df5916df9ed0105701eae40a8246 100644 --- a/src/runtime2/tests/mod.rs +++ b/src/runtime2/tests/mod.rs @@ -31,26 +31,50 @@ fn test_component_creation() { } #[test] -fn test_component_communication() { +fn test_component_communication_a() { let pd = ProtocolDescription::parse(b" primitive sender(out o) { - print(\"sender\"); sync put(o, 1); } primitive receiver(in i) { - print(\"receiver\"); sync auto a = 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); + create_component(&rt, "", "constructor", no_args()); +} + +#[test] +fn test_component_communication_b() { + let pd = ProtocolDescription::parse(b" + primitive sender(out o, u32 rounds) { + u32 index = 0; + sync while (index < rounds) { + put(o, index); + index += 1; + } + } + + primitive receiver(in i, u32 rounds) { + u32 index = 0; + sync while (index < rounds) { + auto val = get(i); + while (val != index) {} // infinite loop if incorrect value is received + index += 1; + } + } + + composite constructor() { + channel o -> i; + new sender(o, 5); + new receiver(i, 5); + }").expect("compilation"); + let rt = Runtime::new(1, pd); create_component(&rt, "", "constructor", no_args()); } \ No newline at end of file