diff --git a/src/runtime2/tests/api_component.rs b/src/runtime2/tests/api_component.rs index 28f7101520dec6d0d1c9075645339ecec5f161a5..67271d2986bb610f91a18425edff20de76b0b0f2 100644 --- a/src/runtime2/tests/api_component.rs +++ b/src/runtime2/tests/api_component.rs @@ -121,4 +121,38 @@ fn test_putting_to_component() { // Note: if we finish a round, then it must have succeeded :) api.wait().expect("finish sync round"); } +} + +#[test] +fn test_doing_nothing() { + const CODE: &'static str = " + primitive getter(in input, u32 num_loops) { + u32 index = 0; + while (index < num_loops) { + sync {} + sync { auto res = get(input); assert(res); } + index += 1; + } + } + "; + + let pd = ProtocolDescription::parse(CODE.as_bytes()).unwrap(); + let rt = Runtime::new(NUM_THREADS, pd); + let mut api = rt.create_interface(); + + let channel = api.create_channel().unwrap(); + api.create_connector("", "getter", ValueGroup::new_stack(vec![ + Value::Input(PortId::new(channel.getter_id.index)), + Value::UInt32(NUM_LOOPS), + ])).unwrap(); + + for _ in 0..NUM_LOOPS { + api.perform_sync_round(vec![]).expect("start silent sync round"); + api.wait().expect("finish silent sync round"); + api.perform_sync_round(vec![ + ApplicationSyncAction::Put(channel.putter_id, ValueGroup::new_stack(vec![Value::Bool(true)])) + ]).expect("start firing sync round"); + let res = api.wait().expect("finish firing sync round"); + assert!(res.is_empty()); + } } \ No newline at end of file