Files
@ 3f2759e5fc57
Branch filter:
Location: CSY/reowolf/src/runtime2/tests/mod.rs - annotation
3f2759e5fc57
1.5 KiB
application/rls-services+xml
somewhat correctly handling port closing and rerouting
665aa326769e 665aa326769e 7d01f1245b7c 7d01f1245b7c 7d01f1245b7c 665aa326769e 665aa326769e 7d01f1245b7c 7d01f1245b7c 7d01f1245b7c 665aa326769e 7d01f1245b7c 7d01f1245b7c 665aa326769e 7d01f1245b7c 7d01f1245b7c 3f2759e5fc57 7d01f1245b7c 7d01f1245b7c 7d01f1245b7c 7d01f1245b7c 7d01f1245b7c 7d01f1245b7c 7d01f1245b7c 7d01f1245b7c 665aa326769e 7d01f1245b7c 7d01f1245b7c 7d01f1245b7c 7d01f1245b7c 7d01f1245b7c 7d01f1245b7c 7d01f1245b7c 7d01f1245b7c 7d01f1245b7c 3f2759e5fc57 665aa326769e 7d01f1245b7c 7d01f1245b7c 7d01f1245b7c 7d01f1245b7c 665aa326769e 7d01f1245b7c 7d01f1245b7c 3f2759e5fc57 665aa326769e 7d01f1245b7c 7d01f1245b7c 7d01f1245b7c 7d01f1245b7c 665aa326769e 7d01f1245b7c 7d01f1245b7c 7d01f1245b7c 7d01f1245b7c 665aa326769e 7d01f1245b7c ff6ade8b8097 | use std::sync::Arc;
use super::*;
use crate::{PortId, ProtocolDescription};
use crate::common::Id;
use crate::protocol::eval::*;
fn runtime_for(num_threads: u32, pdl: &str) -> Runtime {
let protocol = ProtocolDescription::parse(pdl.as_bytes()).expect("parse pdl");
let runtime = Runtime::new(num_threads, protocol);
return runtime;
}
#[test]
fn test_put_and_get() {
let rt = runtime_for(4, "
primitive putter(out<bool> sender, u32 loops) {
u32 index = 0;
while (index < loops) {
synchronous {
print(\"putting!\");
put(sender, true);
}
index += 1;
}
}
primitive getter(in<bool> receiver, u32 loops) {
u32 index = 0;
while (index < loops) {
synchronous {
print(\"getting!\");
auto result = get(receiver);
assert(result);
}
index += 1;
}
}
");
let mut api = rt.create_interface();
let channel = api.create_channel();
let num_loops = 100;
api.create_connector("", "putter", ValueGroup::new_stack(vec![
Value::Output(PortId(Id{ connector_id: 0, u32_suffix: channel.putter_id.index })),
Value::UInt32(num_loops)
])).expect("create putter");
api.create_connector("", "getter", ValueGroup::new_stack(vec![
Value::Input(PortId(Id{ connector_id: 0, u32_suffix: channel.getter_id.index })),
Value::UInt32(num_loops)
])).expect("create getter");
println!("Am I running?");
}
|