2023-10-02 01:45:54 +02:00
|
|
|
use {
|
|
|
|
crate::{term::*, dict::*, parser::*},
|
|
|
|
std::str::FromStr
|
|
|
|
};
|
|
|
|
|
|
|
|
//<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>\\
|
2023-10-01 17:10:40 +02:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_curry() {
|
2023-10-02 01:45:54 +02:00
|
|
|
assert_eq!(
|
|
|
|
TypeTerm::from_str("<A B C>").unwrap().curry(),
|
|
|
|
TypeTerm::from_str("<<A B> C>").unwrap()
|
|
|
|
);
|
|
|
|
assert_eq!(
|
|
|
|
TypeTerm::from_str("<A B C D>").unwrap().curry(),
|
|
|
|
TypeTerm::from_str("<<<A B> C> D>").unwrap()
|
|
|
|
);
|
|
|
|
assert_eq!(
|
|
|
|
TypeTerm::from_str("<A B C D E F G H I J K>").unwrap().curry(),
|
|
|
|
TypeTerm::from_str("<<<<<<<<<<A B> C> D> E> F> G> H> I> J> K>").unwrap()
|
|
|
|
);
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
TypeTerm::from_str("<A~X B C>").unwrap().curry(),
|
|
|
|
TypeTerm::from_str("<<A~X B> C>").unwrap()
|
|
|
|
);
|
|
|
|
assert_eq!(
|
|
|
|
TypeTerm::from_str("<A B C~Y~Z> ~ K").unwrap().curry(),
|
|
|
|
TypeTerm::from_str("< <A B> C~Y~Z > ~ K").unwrap()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_decurry() {
|
|
|
|
assert_eq!(
|
|
|
|
TypeTerm::from_str("<<A B> C>").unwrap().decurry(),
|
|
|
|
TypeTerm::from_str("<A B C>").unwrap()
|
|
|
|
);
|
|
|
|
assert_eq!(
|
|
|
|
TypeTerm::from_str("<<<A B> C> D>").unwrap().decurry(),
|
|
|
|
TypeTerm::from_str("<A B C D>").unwrap(),
|
|
|
|
);
|
|
|
|
assert_eq!(
|
|
|
|
TypeTerm::from_str("<<<<<<<<<<A B> C> D> E> F> G> H> I> J> K>").unwrap().decurry(),
|
|
|
|
TypeTerm::from_str("<A B C D E F G H I J K>").unwrap()
|
|
|
|
);
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
TypeTerm::from_str("<<A~X B> C>").unwrap().decurry(),
|
|
|
|
TypeTerm::from_str("<A~X B C>").unwrap()
|
|
|
|
);
|
|
|
|
assert_eq!(
|
|
|
|
TypeTerm::from_str("<<A~X B> C~Y>~K").unwrap().decurry(),
|
|
|
|
TypeTerm::from_str("<A~X B C~Y> ~K").unwrap()
|
|
|
|
);
|
2023-10-01 17:10:40 +02:00
|
|
|
}
|
|
|
|
|
2023-10-02 01:45:54 +02:00
|
|
|
//<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>\\
|