Skip to content

Commit

Permalink
fix: tests (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshka authored Nov 12, 2024
1 parent 261fdfd commit f833f10
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ indoc = "2.0.5"
pretty_assertions = "1.4.1"
proc-macro2 = "1.0.89"
quote = "1.0.26"
syn = { version = "2", features = ["derive", "full"] }
syn = { version = "2.0.15", features = ["derive", "full"] }

[lib]
proc-macro = true
Expand Down
55 changes: 33 additions & 22 deletions src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,12 @@ mod tests {
};
let tokens = unstable.expand(item);
let expected = quote! {
#[cfg(feature = "unstable-experimental")]
#[cfg(any(doc, feature = "unstable-experimental"))]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable-experimental")))]
#[doc = #WITH_FEATURES_DOC]
pub type Foo = Bar;

#[cfg(not(feature = "unstable-experimental"))]
#[cfg(not(any(doc, feature = "unstable-experimental")))]
#[allow(dead_code)]
#[doc = #WITH_FEATURES_DOC]
pub(crate) type Foo = Bar;
Expand All @@ -152,12 +153,13 @@ mod tests {
};
let tokens = unstable.expand(item);
let expected = quote! {
#[cfg(feature = "unstable")]
#[cfg(any(doc, feature = "unstable"))]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable")))]
#[doc = #DEFAULT_DOC]
#[doc = #ISSUE_DOC]
pub type Foo = Bar;

#[cfg(not(feature = "unstable"))]
#[cfg(not(any(doc, feature = "unstable")))]
#[allow(dead_code)]
#[doc = #DEFAULT_DOC]
#[doc = #ISSUE_DOC]
Expand All @@ -171,11 +173,12 @@ mod tests {
let item: syn::ItemType = parse_quote! { pub type Foo = Bar; };
let tokens = UnstableAttribute::default().expand(item);
let expected = quote! {
#[cfg(feature = "unstable")]
#[cfg(any(doc, feature = "unstable"))]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable")))]
#[doc = #DEFAULT_DOC]
pub type Foo = Bar;

#[cfg(not(feature = "unstable"))]
#[cfg(not(any(doc, feature = "unstable")))]
#[allow(dead_code)]
#[doc = #DEFAULT_DOC]
pub(crate) type Foo = Bar;
Expand All @@ -192,13 +195,14 @@ mod tests {
};
let tokens = UnstableAttribute::default().expand(item);
let expected = quote! {
#[cfg(feature = "unstable")]
#[cfg(any(doc, feature = "unstable"))]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable")))]
#[doc = #DEFAULT_DOC]
pub struct Foo {
pub field: i32,
}

#[cfg(not(feature = "unstable"))]
#[cfg(not(any(doc, feature = "unstable")))]
#[allow(dead_code)]
#[doc = #DEFAULT_DOC]
pub(crate) struct Foo {
Expand All @@ -218,14 +222,15 @@ mod tests {
};
let tokens = UnstableAttribute::default().expand(item);
let expected = quote! {
#[cfg(feature = "unstable")]
#[cfg(any(doc, feature = "unstable"))]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable")))]
#[doc = #DEFAULT_DOC]
pub enum Foo {
A,
B,
}

#[cfg(not(feature = "unstable"))]
#[cfg(not(any(doc, feature = "unstable")))]
#[allow(dead_code)]
#[doc = #DEFAULT_DOC]
pub(crate) enum Foo {
Expand All @@ -243,11 +248,12 @@ mod tests {
};
let tokens = UnstableAttribute::default().expand(item);
let expected = quote! {
#[cfg(feature = "unstable")]
#[cfg(any(doc, feature = "unstable"))]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable")))]
#[doc = #DEFAULT_DOC]
pub fn foo() {}

#[cfg(not(feature = "unstable"))]
#[cfg(not(any(doc, feature = "unstable")))]
#[allow(dead_code)]
#[doc = #DEFAULT_DOC]
pub(crate) fn foo() {}
Expand All @@ -264,13 +270,14 @@ mod tests {
};
let tokens = UnstableAttribute::default().expand(item);
let expected = quote! {
#[cfg(feature = "unstable")]
#[cfg(any(doc, feature = "unstable"))]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable")))]
#[doc = #DEFAULT_DOC]
pub trait Foo {
fn bar(&self);
}

#[cfg(not(feature = "unstable"))]
#[cfg(not(any(doc, feature = "unstable")))]
#[allow(dead_code)]
#[doc = #DEFAULT_DOC]
pub(crate) trait Foo {
Expand All @@ -287,11 +294,12 @@ mod tests {
};
let tokens = UnstableAttribute::default().expand(item);
let expected = quote! {
#[cfg(feature = "unstable")]
#[cfg(any(doc, feature = "unstable"))]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable")))]
#[doc = #DEFAULT_DOC]
pub const FOO: i32 = 42;

#[cfg(not(feature = "unstable"))]
#[cfg(not(any(doc, feature = "unstable")))]
#[allow(dead_code)]
#[doc = #DEFAULT_DOC]
pub(crate) const FOO: i32 = 42;
Expand All @@ -306,11 +314,12 @@ mod tests {
};
let tokens = UnstableAttribute::default().expand(item);
let expected = quote! {
#[cfg(feature = "unstable")]
#[cfg(any(doc, feature = "unstable"))]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable")))]
#[doc = #DEFAULT_DOC]
pub static FOO: i32 = 42;

#[cfg(not(feature = "unstable"))]
#[cfg(not(any(doc, feature = "unstable")))]
#[allow(dead_code)]
#[doc = #DEFAULT_DOC]
pub(crate) static FOO: i32 = 42;
Expand All @@ -327,13 +336,14 @@ mod tests {
};
let tokens = UnstableAttribute::default().expand(item);
let expected = quote! {
#[cfg(feature = "unstable")]
#[cfg(any(doc, feature = "unstable"))]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable")))]
#[doc = #DEFAULT_DOC]
pub mod foo {
pub fn bar() {}
}

#[cfg(not(feature = "unstable"))]
#[cfg(not(any(doc, feature = "unstable")))]
#[allow(dead_code)]
#[doc = #DEFAULT_DOC]
pub(crate) mod foo {
Expand All @@ -350,11 +360,12 @@ mod tests {
};
let tokens = UnstableAttribute::default().expand(item);
let expected = quote! {
#[cfg(feature = "unstable")]
#[cfg(any(doc, feature = "unstable"))]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable")))]
#[doc = #DEFAULT_DOC]
pub use crate::foo::bar;

#[cfg(not(feature = "unstable"))]
#[cfg(not(any(doc, feature = "unstable")))]
#[allow(dead_code)]
#[doc = #DEFAULT_DOC]
pub(crate) use crate::foo::bar;
Expand Down

0 comments on commit f833f10

Please sign in to comment.