From 46adf95726727941f64cbf77dacc0bce41901d6b Mon Sep 17 00:00:00 2001 From: stuebinm Date: Mon, 26 Apr 2021 21:48:19 +0200 Subject: substitutions: add test to serde.rs --- serde_dhall/tests/serde.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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(s: &str, x: T) where @@ -149,6 +150,26 @@ mod serde { .is_err()); } + #[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::() + .unwrap(), + Foo::X(1) + ) + } + #[test] fn test_de_untyped() { use std::collections::BTreeMap; -- cgit v1.2.3