forked from extern/nushell
Add a test
This commit is contained in:
parent
1277bfe0fb
commit
1d3483b590
@ -467,3 +467,27 @@ impl<'a, 'de: 'a> de::SeqAccess<'de> for StructDeserializer<'a, 'de> {
|
||||
return Some(self.fields.len());
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::any::type_name;
|
||||
#[test]
|
||||
fn check_type_name_properties() {
|
||||
// This ensures that certain properties for the
|
||||
// std::any::type_name function hold, that
|
||||
// this code relies on. The type_name docs explicitly
|
||||
// mention that the actual format of the output
|
||||
// is unspecified and change is likely.
|
||||
// This test makes sure that such change is detected
|
||||
// by this test failing, and not things silently breaking.
|
||||
// Specifically, we rely on this behaviour further above
|
||||
// in the file to special case Tagged<Value> parsing.
|
||||
let tuple = type_name::<()>();
|
||||
let tagged_tuple = type_name::<Tagged<()>>();
|
||||
let tagged_value = type_name::<Tagged<Value>>();
|
||||
assert!(tuple != tagged_tuple);
|
||||
assert!(tuple != tagged_value);
|
||||
assert!(tagged_tuple != tagged_value);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user