Files @ d06da4e9296c
Branch filter:

Location: CSY/reowolf/src/runtime2/tests/mod.rs - annotation

d06da4e9296c 1.4 KiB application/rls-services+xml Show Source Show as Raw Download as Raw
mh
WIP: Reimplementing messaging and consensus
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, true);
        rt.inner.enqueue_work(key);
    }
}

#[test]
fn test_component_communication() {
    let pd = ProtocolDescription::parse(b"
    primitive sender(out<u32> o) {
        print(\"sender\");
        sync put(o, 1);
    }
    primitive receiver(in<u32> 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), true);
    rt.inner.enqueue_work(key);
}