Test never_type

This commit is contained in:
David Tolnay 2018-06-03 00:15:05 -07:00
parent fd6178cad6
commit 22b1af7eb3
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
2 changed files with 37 additions and 0 deletions

View File

@ -7,6 +7,7 @@
// except according to those terms.
#![cfg_attr(feature = "cargo-clippy", allow(decimal_literal_representation))]
#![cfg_attr(feature = "unstable", feature(never_type))]
#[macro_use]
extern crate serde_derive;
@ -984,6 +985,16 @@ declare_tests! {
}
}
#[cfg(feature = "unstable")]
declare_tests! {
test_never_result {
Ok::<u8, !>(0) => &[
Token::NewtypeVariant { name: "Result", variant: "Ok" },
Token::U8(0),
],
}
}
#[cfg(unix)]
#[test]
fn test_osstring() {
@ -1051,6 +1062,20 @@ fn test_cstr_internal_null_end() {
);
}
#[cfg(feature = "unstable")]
#[test]
fn test_never_type() {
assert_de_tokens_error::<!>(&[], "cannot deserialize `!`");
assert_de_tokens_error::<Result<u8, !>>(
&[Token::NewtypeVariant {
name: "Result",
variant: "Err",
}],
"cannot deserialize `!`",
);
}
declare_error_tests! {
test_unknown_field<StructDenyUnknown> {
&[

View File

@ -6,6 +6,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![cfg_attr(feature = "unstable", feature(never_type))]
#[macro_use]
extern crate serde_derive;
@ -548,6 +550,16 @@ declare_tests! {
}
}
#[cfg(feature = "unstable")]
declare_tests! {
test_never_result {
Ok::<u8, !>(0) => &[
Token::NewtypeVariant { name: "Result", variant: "Ok" },
Token::U8(0),
],
}
}
#[test]
#[cfg(unix)]
fn test_cannot_serialize_paths() {