summaryrefslogtreecommitdiff
path: root/dhall/tests/traits.rs
diff options
context:
space:
mode:
Diffstat (limited to 'dhall/tests/traits.rs')
-rw-r--r--dhall/tests/traits.rs67
1 files changed, 32 insertions, 35 deletions
diff --git a/dhall/tests/traits.rs b/dhall/tests/traits.rs
index 65220dc..75eaf75 100644
--- a/dhall/tests/traits.rs
+++ b/dhall/tests/traits.rs
@@ -1,79 +1,76 @@
#![feature(proc_macro_hygiene)]
-use dhall::de::SimpleStaticType;
-use dhall_proc_macros;
+use dhall::de::{StaticType, Type};
+use dhall_proc_macros::subexpr;
use dhall_syntax::{SubExpr, X};
#[test]
fn test_static_type() {
- fn mktype(x: SubExpr<X, X>) -> dhall::de::SimpleType {
- x.into()
+ fn mktype(x: SubExpr<X, X>) -> Type {
+ Type::from_normalized_expr(x)
}
+ assert_eq!(bool::static_type(), mktype(subexpr!(Bool)));
+ assert_eq!(String::static_type(), mktype(subexpr!(Text)));
assert_eq!(
- bool::get_simple_static_type(),
- mktype(dhall_proc_macros::subexpr!(Bool))
+ <Option<bool>>::static_type(),
+ mktype(subexpr!(Optional Bool))
);
assert_eq!(
- String::get_simple_static_type(),
- mktype(dhall_proc_macros::subexpr!(Text))
- );
- assert_eq!(
- <Option<bool>>::get_simple_static_type(),
- mktype(dhall_proc_macros::subexpr!(Optional Bool))
- );
- assert_eq!(
- <(bool, Option<String>)>::get_simple_static_type(),
- mktype(dhall_proc_macros::subexpr!({ _1: Bool, _2: Optional Text }))
+ <(bool, Vec<String>)>::static_type(),
+ mktype(subexpr!({ _1: Bool, _2: List Text }))
);
- #[derive(dhall::de::SimpleStaticType)]
+ #[derive(dhall::de::StaticType)]
#[allow(dead_code)]
struct A {
field1: bool,
field2: Option<bool>,
}
assert_eq!(
- <A as dhall::de::SimpleStaticType>::get_simple_static_type(),
- mktype(
- dhall_proc_macros::subexpr!({ field1: Bool, field2: Optional Bool })
- )
+ <A as dhall::de::StaticType>::static_type(),
+ mktype(subexpr!({ field1: Bool, field2: Optional Bool }))
);
- #[derive(SimpleStaticType)]
+ #[derive(StaticType)]
#[allow(dead_code)]
struct B<'a, T: 'a> {
field1: &'a T,
field2: Option<T>,
}
- assert_eq!(
- <B<'static, bool>>::get_simple_static_type(),
- A::get_simple_static_type()
- );
+ assert_eq!(<B<'static, bool>>::static_type(), A::static_type());
- #[derive(SimpleStaticType)]
+ #[derive(StaticType)]
#[allow(dead_code)]
struct C<T>(T, Option<String>);
assert_eq!(
- <C<bool>>::get_simple_static_type(),
- <(bool, Option<String>)>::get_simple_static_type()
+ <C<bool>>::static_type(),
+ <(bool, Option<String>)>::static_type()
);
- #[derive(SimpleStaticType)]
+ #[derive(StaticType)]
#[allow(dead_code)]
struct D();
assert_eq!(
- <C<D>>::get_simple_static_type(),
- mktype(dhall_proc_macros::subexpr!({ _1: {}, _2: Optional Text }))
+ <C<D>>::static_type(),
+ mktype(subexpr!({ _1: {}, _2: Optional Text }))
);
- #[derive(SimpleStaticType)]
+ #[derive(StaticType)]
#[allow(dead_code)]
enum E<T> {
A(T),
B(String),
};
assert_eq!(
- <E<bool>>::get_simple_static_type(),
- mktype(dhall_proc_macros::subexpr!(< A: Bool | B: Text >))
+ <E<bool>>::static_type(),
+ mktype(subexpr!(< A: Bool | B: Text >))
);
+
+ #[derive(StaticType)]
+ #[allow(dead_code)]
+ enum F {
+ A,
+ B(bool),
+ };
+ assert_eq!(F::static_type(), mktype(subexpr!(< A | B: Bool >)));
}