diff --git a/Cargo.lock b/Cargo.lock index a210b52..fd2ae3e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -278,6 +278,12 @@ dependencies = [ "syn", ] +[[package]] +name = "dissimilar" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c97b9233581d84b8e1e689cdd3a47b6f69770084fc246e86a7f78b0d9c1d4a5" + [[package]] name = "downcast-rs" version = "1.2.0" @@ -312,6 +318,12 @@ dependencies = [ "void", ] +[[package]] +name = "glob" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" + [[package]] name = "hash32" version = "0.2.1" @@ -377,6 +389,12 @@ dependencies = [ "cxx-build", ] +[[package]] +name = "itoa" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" + [[package]] name = "js-sys" version = "0.3.60" @@ -595,6 +613,12 @@ dependencies = [ "semver 1.0.14", ] +[[package]] +name = "ryu" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" + [[package]] name = "satrs-core" version = "0.1.0" @@ -628,12 +652,14 @@ dependencies = [ ] [[package]] -name = "satrs-macro" +name = "satrs-macros" version = "0.1.0" dependencies = [ "proc-macro2", "quote", + "satrs-core", "syn", + "trybuild", ] [[package]] @@ -689,6 +715,17 @@ dependencies = [ "syn", ] +[[package]] +name = "serde_json" +version = "1.0.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "020ff22c755c2ed3f8cf162dbb41a7268d934702f3ed3631656ea597e08fc3db" +dependencies = [ + "itoa", + "ryu", + "serde", +] + [[package]] name = "smallvec" version = "1.10.0" @@ -743,6 +780,31 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "toml" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" +dependencies = [ + "serde", +] + +[[package]] +name = "trybuild" +version = "1.0.71" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea496675d71016e9bc76aa42d87f16aefd95447cc5818e671e12b2d7e269075d" +dependencies = [ + "dissimilar", + "glob", + "once_cell", + "serde", + "serde_derive", + "serde_json", + "termcolor", + "toml", +] + [[package]] name = "unicode-ident" version = "1.0.5" diff --git a/satrs-macros/Cargo.toml b/satrs-macros/Cargo.toml index 7f56423..9c67bea 100644 --- a/satrs-macros/Cargo.toml +++ b/satrs-macros/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "satrs-macro" +name = "satrs-macros" version = "0.1.0" edition = "2021" @@ -7,10 +7,20 @@ edition = "2021" [lib] proc-macro = true +[[test]] +name = "tests" +path = "tests/tests.rs" + [dependencies] quote = "1.0" proc-macro2 = "1.0" +[dependencies.satrs-core] +path = "../satrs-core" + +[dev-dependencies] +trybuild = { version = "1.0", features = ["diff"] } + [dependencies.syn] version = "1.0" features = ["extra-traits"] diff --git a/satrs-macros/src/lib.rs b/satrs-macros/src/lib.rs index 8b13789..7bcd0cd 100644 --- a/satrs-macros/src/lib.rs +++ b/satrs-macros/src/lib.rs @@ -1 +1,7 @@ - +#[proc_macro_attribute] +pub fn result( + _attr: proc_macro::TokenStream, + item: proc_macro::TokenStream, +) -> proc_macro::TokenStream { + item +} diff --git a/satrs-macros/tests/basic.rs b/satrs-macros/tests/basic.rs new file mode 100644 index 0000000..f9a8210 --- /dev/null +++ b/satrs-macros/tests/basic.rs @@ -0,0 +1,7 @@ +use satrs_core::resultcode::ResultU16; +use satrs_macros::*; + +#[result] +const TEST_RESULT: ResultU16 = ResultU16::const_new(0, 1); + +fn main() {} diff --git a/satrs-macros/tests/tests.rs b/satrs-macros/tests/tests.rs new file mode 100644 index 0000000..71b63af --- /dev/null +++ b/satrs-macros/tests/tests.rs @@ -0,0 +1,5 @@ +#[test] +fn tests() { + let t = trybuild::TestCases::new(); + t.pass("tests/basic.rs"); +}