summaryrefslogtreecommitdiff
path: root/serde_dhall/tests
diff options
context:
space:
mode:
Diffstat (limited to 'serde_dhall/tests')
-rw-r--r--serde_dhall/tests/serde.rs21
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;