diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-18 02:49:50 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-18 02:49:50 +0000 |
commit | 9835e2ae736235810b4ea1c162ca5e65c547e770 (patch) | |
tree | 3fcebf40ed70e581d776a8a4c65923e8ec20e026 /vendor/syn-1.0.109/tests/test_receiver.rs | |
parent | Releasing progress-linux version 1.70.0+dfsg2-1~progress7.99u1. (diff) | |
download | rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.tar.xz rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.zip |
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/syn-1.0.109/tests/test_receiver.rs')
-rw-r--r-- | vendor/syn-1.0.109/tests/test_receiver.rs | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/vendor/syn-1.0.109/tests/test_receiver.rs b/vendor/syn-1.0.109/tests/test_receiver.rs new file mode 100644 index 000000000..923df96ba --- /dev/null +++ b/vendor/syn-1.0.109/tests/test_receiver.rs @@ -0,0 +1,127 @@ +use syn::{parse_quote, FnArg, Receiver, TraitItemMethod}; + +#[test] +fn test_by_value() { + let TraitItemMethod { sig, .. } = parse_quote! { + fn by_value(self: Self); + }; + match sig.receiver() { + Some(FnArg::Typed(_)) => (), + value => panic!("expected FnArg::Typed, got {:?}", value), + } +} + +#[test] +fn test_by_mut_value() { + let TraitItemMethod { sig, .. } = parse_quote! { + fn by_mut(mut self: Self); + }; + match sig.receiver() { + Some(FnArg::Typed(_)) => (), + value => panic!("expected FnArg::Typed, got {:?}", value), + } +} + +#[test] +fn test_by_ref() { + let TraitItemMethod { sig, .. } = parse_quote! { + fn by_ref(self: &Self); + }; + match sig.receiver() { + Some(FnArg::Typed(_)) => (), + value => panic!("expected FnArg::Typed, got {:?}", value), + } +} + +#[test] +fn test_by_box() { + let TraitItemMethod { sig, .. } = parse_quote! { + fn by_box(self: Box<Self>); + }; + match sig.receiver() { + Some(FnArg::Typed(_)) => (), + value => panic!("expected FnArg::Typed, got {:?}", value), + } +} + +#[test] +fn test_by_pin() { + let TraitItemMethod { sig, .. } = parse_quote! { + fn by_pin(self: Pin<Self>); + }; + match sig.receiver() { + Some(FnArg::Typed(_)) => (), + value => panic!("expected FnArg::Typed, got {:?}", value), + } +} + +#[test] +fn test_explicit_type() { + let TraitItemMethod { sig, .. } = parse_quote! { + fn explicit_type(self: Pin<MyType>); + }; + match sig.receiver() { + Some(FnArg::Typed(_)) => (), + value => panic!("expected FnArg::Typed, got {:?}", value), + } +} + +#[test] +fn test_value_shorthand() { + let TraitItemMethod { sig, .. } = parse_quote! { + fn value_shorthand(self); + }; + match sig.receiver() { + Some(FnArg::Receiver(Receiver { + reference: None, + mutability: None, + .. + })) => (), + value => panic!("expected FnArg::Receiver without ref/mut, got {:?}", value), + } +} + +#[test] +fn test_mut_value_shorthand() { + let TraitItemMethod { sig, .. } = parse_quote! { + fn mut_value_shorthand(mut self); + }; + match sig.receiver() { + Some(FnArg::Receiver(Receiver { + reference: None, + mutability: Some(_), + .. + })) => (), + value => panic!("expected FnArg::Receiver with mut, got {:?}", value), + } +} + +#[test] +fn test_ref_shorthand() { + let TraitItemMethod { sig, .. } = parse_quote! { + fn ref_shorthand(&self); + }; + match sig.receiver() { + Some(FnArg::Receiver(Receiver { + reference: Some(_), + mutability: None, + .. + })) => (), + value => panic!("expected FnArg::Receiver with ref, got {:?}", value), + } +} + +#[test] +fn test_ref_mut_shorthand() { + let TraitItemMethod { sig, .. } = parse_quote! { + fn ref_mut_shorthand(&mut self); + }; + match sig.receiver() { + Some(FnArg::Receiver(Receiver { + reference: Some(_), + mutability: Some(_), + .. + })) => (), + value => panic!("expected FnArg::Receiver with ref+mut, got {:?}", value), + } +} |