summaryrefslogtreecommitdiff
path: root/serde_dhall/tests/de.rs
diff options
context:
space:
mode:
Diffstat (limited to 'serde_dhall/tests/de.rs')
-rw-r--r--serde_dhall/tests/de.rs59
1 files changed, 1 insertions, 58 deletions
diff --git a/serde_dhall/tests/de.rs b/serde_dhall/tests/de.rs
index 3abaad2..0b43de2 100644
--- a/serde_dhall/tests/de.rs
+++ b/serde_dhall/tests/de.rs
@@ -1,62 +1,5 @@
use serde::Deserialize;
-use serde_dhall::{from_str, FromDhall, NumKind, SimpleValue, StaticType};
-
-#[test]
-fn test_de_typed() {
- fn parse<T: FromDhall + StaticType>(s: &str) -> T {
- from_str(s).static_type_annotation().parse().unwrap()
- }
-
- assert_eq!(parse::<bool>("True"), true);
-
- assert_eq!(parse::<u64>("1"), 1);
- assert_eq!(parse::<u32>("1"), 1);
- assert_eq!(parse::<usize>("1"), 1);
-
- assert_eq!(parse::<i64>("+1"), 1);
- assert_eq!(parse::<i32>("+1"), 1);
- assert_eq!(parse::<isize>("+1"), 1);
-
- assert_eq!(parse::<f64>("1.0"), 1.0);
- assert_eq!(parse::<f32>("1.0"), 1.0);
-
- assert_eq!(parse::<String>(r#""foo""#), "foo".to_owned());
- assert_eq!(parse::<Vec<u64>>("[] : List Natural"), <Vec<u64>>::new());
- assert_eq!(parse::<Vec<u64>>("[1, 2]"), vec![1, 2]);
- assert_eq!(parse::<Option<u64>>("None Natural"), None);
- assert_eq!(parse::<Option<u64>>("Some 1"), Some(1));
-
- assert_eq!(
- parse::<(u64, String)>(r#"{ _1 = 1, _2 = "foo" }"#),
- (1, "foo".to_owned())
- );
-
- #[derive(Debug, PartialEq, Eq, Deserialize, StaticType)]
- struct Foo {
- x: u64,
- y: i64,
- }
- assert_eq!(parse::<Foo>("{ x = 1, y = -2 }"), Foo { x: 1, y: -2 });
-
- #[derive(Debug, PartialEq, Eq, Deserialize, StaticType)]
- enum Bar {
- X(u64),
- Y(i64),
- }
- assert_eq!(parse::<Bar>("< X: Natural | Y: Integer >.X 1"), Bar::X(1));
-
- #[derive(Debug, PartialEq, Eq, Deserialize, StaticType)]
- enum Baz {
- X,
- Y(i64),
- }
- assert_eq!(parse::<Baz>("< X | Y: Integer >.X"), Baz::X);
-
- assert!(from_str("< X | Y: Integer >.Y")
- .static_type_annotation()
- .parse::<Baz>()
- .is_err());
-}
+use serde_dhall::{from_str, FromDhall, NumKind, SimpleValue};
#[test]
fn test_de_untyped() {