diff --git a/modules/dummy/Cargo.toml b/modules/dummy/Cargo.toml new file mode 100644 index 0000000..5009419 --- /dev/null +++ b/modules/dummy/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "dummy" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[lib] +crate-type = ["cdylib"] + +[dependencies] +sdk = { path = "../sdk" } \ No newline at end of file diff --git a/modules/dummy/src/lib.rs b/modules/dummy/src/lib.rs new file mode 100644 index 0000000..f959abb --- /dev/null +++ b/modules/dummy/src/lib.rs @@ -0,0 +1,29 @@ +use sdk::BoxFuture; +use sdk::initiators::{Initiator, InitiatorError, ResourceID, UpdateSink}; + +#[sdk::module] +struct Dummy { + a: u32, + b: u32, + c: u32, + d: u32, +} + +impl Initiator for Dummy { + fn start_for(&mut self, machine: ResourceID) -> BoxFuture<'static, Result<(), Box>> { + todo!() + } + + fn run(&mut self, request: &mut UpdateSink) -> BoxFuture<'static, Result<(), Box>> { + todo!() + } +} + +#[cfg(test)] +mod tests { + #[test] + fn it_works() { + let result = 2 + 2; + assert_eq!(result, 4); + } +} diff --git a/modules/sdk/sdk_proc/Cargo.toml b/modules/sdk/sdk_proc/Cargo.toml new file mode 100644 index 0000000..0b5bf28 --- /dev/null +++ b/modules/sdk/sdk_proc/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "sdk-proc" +version = "0.1.0" +edition = "2021" +autotests = false + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[lib] +proc-macro = true + +[[test]] +name = "tests" +path = "tests/progress.rs" + +[dev-dependencies] +trybuild = "1.0" + +[dependencies] +proc-macro2 = "1.0" +syn = "1.0" +quote = "1.0" diff --git a/modules/sdk/sdk_proc/tests/02-not-or-bad-struct.stderr b/modules/sdk/sdk_proc/tests/02-not-or-bad-struct.stderr new file mode 100644 index 0000000..800b6b5 --- /dev/null +++ b/modules/sdk/sdk_proc/tests/02-not-or-bad-struct.stderr @@ -0,0 +1,11 @@ +error: Modules must be structs + --> tests/02-not-or-bad-struct.rs:4:1 + | +4 | enum EnumModule { + | ^^^^ + +error: Modules can't be unit structs + --> tests/02-not-or-bad-struct.rs:9:24 + | +9 | struct UnitStructModule; + | ^ diff --git a/modules/sdk/sdk_proc/tests/progress.rs b/modules/sdk/sdk_proc/tests/progress.rs new file mode 100644 index 0000000..37c2397 --- /dev/null +++ b/modules/sdk/sdk_proc/tests/progress.rs @@ -0,0 +1,12 @@ +#[test] +fn tests() { + let t = trybuild::TestCases::new(); + t.pass("tests/01-parse-struct.rs"); + t.compile_fail("tests/02-not-or-bad-struct.rs"); + //t.compile_fail("tests/03-out-of-order.rs"); + //t.compile_fail("tests/04-variants-with-data.rs"); + //t.compile_fail("tests/05-match-expr.rs"); + //t.compile_fail("tests/06-pattern-path.rs"); + //t.compile_fail("tests/07-unrecognized-pattern.rs"); + //t.pass("tests/08-underscore.rs"); +}