summaryrefslogtreecommitdiff
path: root/dhall/tests
diff options
context:
space:
mode:
authorNadrieril2019-04-10 19:16:11 +0200
committerNadrieril2019-04-10 19:16:11 +0200
commite1a30c6f248c0c17c97598290a0d94993dbb0325 (patch)
tree960eb4029f2ba9a824e34219915e942b1b65e4cd /dhall/tests
parent982f86c34f69bb78b45a4b8b37a5bf5731f881eb (diff)
Add SimpleType and SimpeStaticType. Derive the latter
Diffstat (limited to 'dhall/tests')
-rw-r--r--dhall/tests/traits.rs54
1 files changed, 36 insertions, 18 deletions
diff --git a/dhall/tests/traits.rs b/dhall/tests/traits.rs
index ac6b5e6..1e9b3c2 100644
--- a/dhall/tests/traits.rs
+++ b/dhall/tests/traits.rs
@@ -1,53 +1,71 @@
#![feature(proc_macro_hygiene)]
-use dhall::StaticType;
+use dhall::SimpleStaticType;
+use dhall_core::{SubExpr, X};
use dhall_generator::dhall_expr;
#[test]
-fn test_dhall_type() {
- assert_eq!(bool::get_type(), dhall_expr!(Bool));
- assert_eq!(String::get_type(), dhall_expr!(Text));
+fn test_static_type() {
+ fn mktype(x: SubExpr<X, X>) -> dhall::expr::SimpleType {
+ x.into()
+ }
+
+ assert_eq!(bool::get_simple_static_type(), mktype(dhall_expr!(Bool)));
+ assert_eq!(String::get_simple_static_type(), mktype(dhall_expr!(Text)));
assert_eq!(
- <(bool, Option<String>)>::get_type(),
- dhall_expr!({ _1: Bool, _2: Optional Text })
+ <Option<bool>>::get_simple_static_type(),
+ mktype(dhall_expr!(Optional Bool))
+ );
+ assert_eq!(
+ <(bool, Option<String>)>::get_simple_static_type(),
+ mktype(dhall_expr!({ _1: Bool, _2: Optional Text }))
);
- #[derive(dhall::StaticType)]
+ #[derive(dhall::SimpleStaticType)]
#[allow(dead_code)]
struct A {
field1: bool,
field2: Option<bool>,
}
assert_eq!(
- <A as dhall::StaticType>::get_type(),
- dhall_expr!({ field1: Bool, field2: Optional Bool })
+ <A as dhall::SimpleStaticType>::get_simple_static_type(),
+ mktype(dhall_expr!({ field1: Bool, field2: Optional Bool }))
);
- #[derive(StaticType)]
+ #[derive(SimpleStaticType)]
#[allow(dead_code)]
struct B<'a, T: 'a> {
field1: &'a T,
field2: Option<T>,
}
- assert_eq!(<B<'static, bool>>::get_type(), A::get_type());
+ assert_eq!(
+ <B<'static, bool>>::get_simple_static_type(),
+ A::get_simple_static_type()
+ );
- #[derive(StaticType)]
+ #[derive(SimpleStaticType)]
#[allow(dead_code)]
struct C<T>(T, Option<String>);
- assert_eq!(<C<bool>>::get_type(), <(bool, Option<String>)>::get_type());
+ assert_eq!(
+ <C<bool>>::get_simple_static_type(),
+ <(bool, Option<String>)>::get_simple_static_type()
+ );
- #[derive(StaticType)]
+ #[derive(SimpleStaticType)]
#[allow(dead_code)]
struct D();
assert_eq!(
- <C<D>>::get_type(),
- dhall_expr!({ _1: {}, _2: Optional Text })
+ <C<D>>::get_simple_static_type(),
+ mktype(dhall_expr!({ _1: {}, _2: Optional Text }))
);
- #[derive(StaticType)]
+ #[derive(SimpleStaticType)]
#[allow(dead_code)]
enum E<T> {
A(T),
B(String),
};
- assert_eq!(<E<bool>>::get_type(), dhall_expr!(< A: Bool | B: Text >));
+ assert_eq!(
+ <E<bool>>::get_simple_static_type(),
+ mktype(dhall_expr!(< A: Bool | B: Text >))
+ );
}