Files
@ b7d434ab8020
Branch filter:
Location: CSY/reowolf/src/runtime2/tests/internet.rs - annotation
b7d434ab8020
2.1 KiB
application/rls-services+xml
Remove distinction between primitive/composite components
1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 1cc3bd69b119 | use super::*;
// silly test to make sure that the PDL will never be an issue when doing TCP
// stuff with the actual components
#[test]
fn test_stdlib_file() {
compile_and_create_component("
import std.internet as inet;
primitive fake_listener_once(out<inet::TcpConnection> tx) {
channel cmd_tx -> cmd_rx;
channel data_tx -> data_rx;
new fake_client(cmd_rx, data_tx);
sync put(tx, inet::TcpConnection{
tx: cmd_tx,
rx: data_rx,
});
}
primitive fake_socket(in<inet::Cmd> cmds, out<u8[]> tx) {
auto to_send = {};
auto shutdown = false;
while (!shutdown) {
auto keep_going = true;
sync {
while (keep_going) {
let cmd = get(cmds);
if (let inet::Cmd::Send(data) = cmd) {
to_send = data;
} else if (let inet::Cmd::Receive(data) = cmd) {
put(tx, to_send);
} else if (let inet::Cmd::Finish = cmd) {
keep_going = false;
} else if (let inet::Cmd::Shutdown = cmd) {
keep_going = false;
shutdown = true;
}
}
}
}
}
primitive fake_client(inet::TcpConnection conn) {
sync put(conn.tx, inet::Cmd::Send({1, 3, 3, 7}));
sync {
put(conn.tx, inet::Cmd::Receive);
auto val = get(conn.rx);
while (val[0] != 1 || val[1] != 3 || val[2] != 3 || val[3] != 7) {}
put(conn.tx, inet::Cmd::Finish);
}
sync put(conn.tx, inet::Cmd::Shutdown);
}
composite constructor() {
channel conn_tx -> conn_rx;
new fake_listener_once(conn_tx);
// Same crap as before:
channel cmd_tx -> unused_cmd_rx;
channel unused_data_tx -> data_rx;
auto connection = inet::TcpConnection{ tx: cmd_tx, rx: data_rx };
sync {
connection = get(conn_rx);
}
new fake_client(connection);
}
", "constructor", no_args());
}
|