diff options
author | Nadrieril | 2020-12-08 18:47:41 +0000 |
---|---|---|
committer | GitHub | 2020-12-08 18:47:41 +0000 |
commit | 109dcf894e759bce1c28f9ae94f3fdaa6e08feb5 (patch) | |
tree | 9ce374d02ea15966c7bb2dfb39d5d81720a63687 /serde_dhall/tests | |
parent | 35ed301e8de5a2b1102e370e638564d3c3d204a8 (diff) | |
parent | d0a61179addf838d33e7e7a4c6a13f06e871e9c5 (diff) |
Merge pull request #204 from Nadrieril/source-id
Diffstat (limited to 'serde_dhall/tests')
-rw-r--r-- | serde_dhall/tests/serde.rs | 19 | ||||
-rw-r--r-- | serde_dhall/tests/simple_value.rs | 14 |
2 files changed, 32 insertions, 1 deletions
diff --git a/serde_dhall/tests/serde.rs b/serde_dhall/tests/serde.rs index 1181f72..fe0bffb 100644 --- a/serde_dhall/tests/serde.rs +++ b/serde_dhall/tests/serde.rs @@ -226,6 +226,25 @@ mod serde { Ok(true) ); } + + #[test] + fn test_import() { + assert_de( + "../dhall-lang/tests/parser/success/unit/BoolLitTrueA.dhall", + true, + ); + assert_eq!( + serde_dhall::from_str( + "../dhall-lang/tests/parser/success/unit/BoolLitTrueA.dhall" + ) + .imports(false) + .static_type_annotation() + .parse::<bool>() + .map_err(|e| e.to_string()), + Err("UnexpectedImport(Import { mode: Code, location: Local(Parent, FilePath { file_path: [\"dhall-lang\", \"tests\", \"parser\", \"success\", \"unit\", \"BoolLitTrueA.dhall\"] }), hash: None })".to_string()) + ); + } + // TODO: test various builder configurations // In particular test cloning and reusing builder } diff --git a/serde_dhall/tests/simple_value.rs b/serde_dhall/tests/simple_value.rs index 3bd9d64..3d40da1 100644 --- a/serde_dhall/tests/simple_value.rs +++ b/serde_dhall/tests/simple_value.rs @@ -1,7 +1,7 @@ mod simple_value { use serde::{Deserialize, Serialize}; use serde_dhall::{ - from_str, serialize, FromDhall, NumKind, SimpleValue, ToDhall, + from_str, serialize, FromDhall, NumKind, SimpleValue, ToDhall, Value, }; fn assert_de<T>(s: &str, x: T) @@ -54,5 +54,17 @@ mod simple_value { foo: bool_true.clone(), }, ); + + // Neither a simple value or a simple type. + let not_simple = "Type → Type"; + assert_eq!( + from_str(not_simple) + .parse::<Value>() + .map_err(|e| e.to_string()), + Err(format!( + "this is neither a simple type nor a simple value: {}", + not_simple + )) + ); } } |