diff options
author | stuebinm | 2021-04-26 21:48:19 +0200 |
---|---|---|
committer | stuebinm | 2021-04-26 21:48:19 +0200 |
commit | 46adf95726727941f64cbf77dacc0bce41901d6b (patch) | |
tree | add75f18e29f1a6aeadd930b70ab6b73b9328576 /serde_dhall | |
parent | 9c3d04e84c8f22db4a616cf1a98bd90dc27819cb (diff) |
substitutions: add test to serde.rs
Diffstat (limited to '')
-rw-r--r-- | serde_dhall/tests/serde.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/serde_dhall/tests/serde.rs b/serde_dhall/tests/serde.rs index 78382d0..99e4b8b 100644 --- a/serde_dhall/tests/serde.rs +++ b/serde_dhall/tests/serde.rs @@ -3,6 +3,7 @@ mod serde { use serde_dhall::{ from_str, serialize, FromDhall, StaticType, ToDhall, Value, }; + use std::collections; fn assert_de<T>(s: &str, x: T) where @@ -150,6 +151,26 @@ mod serde { } #[test] + fn substitutions() { + #[derive(Debug, Clone, Deserialize, Serialize, StaticType, Eq, PartialEq)] + enum Foo { + X(u64), + Y(i64), + } + + let mut substs = collections::HashMap::new(); + substs.insert("Foo".to_string(), Foo::static_type()); + + assert_eq!(from_str("Foo.X 1") + .substitute_names(substs) + .static_type_annotation() + .parse::<Foo>() + .unwrap(), + Foo::X(1) + ) + } + + #[test] fn test_de_untyped() { use std::collections::BTreeMap; use std::collections::HashMap; |