Modules state commit

This commit is contained in:
Nadja Reitzenstein 2022-01-05 21:56:32 +01:00
parent 2c1b522021
commit 03ff3fcf86
5 changed files with 86 additions and 0 deletions

12
modules/dummy/Cargo.toml Normal file
View File

@ -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" }

29
modules/dummy/src/lib.rs Normal file
View File

@ -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<dyn InitiatorError>>> {
todo!()
}
fn run(&mut self, request: &mut UpdateSink) -> BoxFuture<'static, Result<(), Box<dyn InitiatorError>>> {
todo!()
}
}
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
let result = 2 + 2;
assert_eq!(result, 4);
}
}

View File

@ -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"

View File

@ -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;
| ^

View File

@ -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");
}