fix tests
This commit is contained in:
parent
1006096690
commit
c6e7acec70
7 changed files with 42 additions and 48 deletions
|
@ -1,12 +1,12 @@
|
|||
use {
|
||||
crate::{dict::*}
|
||||
crate::{dict::*, parser::*}
|
||||
};
|
||||
|
||||
//<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>\\
|
||||
|
||||
#[test]
|
||||
fn test_curry() {
|
||||
let mut dict = TypeDict::new();
|
||||
let mut dict = BimapTypeDict::new();
|
||||
|
||||
assert_eq!(
|
||||
dict.parse("<A B C>").unwrap().curry(),
|
||||
|
@ -33,7 +33,7 @@ fn test_curry() {
|
|||
|
||||
#[test]
|
||||
fn test_decurry() {
|
||||
let mut dict = TypeDict::new();
|
||||
let mut dict = BimapTypeDict::new();
|
||||
|
||||
assert_eq!(
|
||||
dict.parse("<<A B> C>").unwrap().decurry(),
|
||||
|
@ -47,7 +47,7 @@ fn test_decurry() {
|
|||
dict.parse("<<<<<<<<<<A B> C> D> E> F> G> H> I> J> K>").unwrap().decurry(),
|
||||
dict.parse("<A B C D E F G H I J K>").unwrap()
|
||||
);
|
||||
|
||||
|
||||
assert_eq!(
|
||||
dict.parse("<<A~X B> C>").unwrap().decurry(),
|
||||
dict.parse("<A~X B C>").unwrap()
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use crate::dict::TypeDict;
|
||||
use crate::{dict::{BimapTypeDict}, parser::*};
|
||||
|
||||
#[test]
|
||||
fn test_flat() {
|
||||
let mut dict = TypeDict::new();
|
||||
let mut dict = BimapTypeDict::new();
|
||||
|
||||
assert!( dict.parse("A").expect("parse error").is_flat() );
|
||||
assert!( dict.parse("10").expect("parse error").is_flat() );
|
||||
|
@ -17,7 +17,7 @@ fn test_flat() {
|
|||
|
||||
#[test]
|
||||
fn test_normalize() {
|
||||
let mut dict = TypeDict::new();
|
||||
let mut dict = BimapTypeDict::new();
|
||||
|
||||
assert_eq!(
|
||||
dict.parse("A~B~C").expect("parse error").normalize(),
|
||||
|
@ -54,4 +54,3 @@ fn test_normalize() {
|
|||
);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ use {
|
|||
|
||||
#[test]
|
||||
fn test_parser_id() {
|
||||
let mut dict = TypeDict::new();
|
||||
let mut dict = BimapTypeDict::new();
|
||||
|
||||
dict.add_varname("T".into());
|
||||
|
||||
|
@ -26,7 +26,7 @@ fn test_parser_id() {
|
|||
fn test_parser_num() {
|
||||
assert_eq!(
|
||||
Ok(TypeTerm::Num(1234)),
|
||||
TypeDict::new().parse("1234")
|
||||
BimapTypeDict::new().parse("1234")
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -34,21 +34,21 @@ fn test_parser_num() {
|
|||
fn test_parser_char() {
|
||||
assert_eq!(
|
||||
Ok(TypeTerm::Char('x')),
|
||||
TypeDict::new().parse("'x'")
|
||||
BimapTypeDict::new().parse("'x'")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parser_app() {
|
||||
assert_eq!(
|
||||
TypeDict::new().parse("<A B>"),
|
||||
BimapTypeDict::new().parse("<A B>"),
|
||||
Ok(TypeTerm::App(vec![
|
||||
TypeTerm::TypeID(TypeID::Fun(0)),
|
||||
TypeTerm::TypeID(TypeID::Fun(1)),
|
||||
]))
|
||||
);
|
||||
assert_eq!(
|
||||
TypeDict::new().parse("<A B C>"),
|
||||
BimapTypeDict::new().parse("<A B C>"),
|
||||
Ok(TypeTerm::App(vec![
|
||||
TypeTerm::TypeID(TypeID::Fun(0)),
|
||||
TypeTerm::TypeID(TypeID::Fun(1)),
|
||||
|
@ -60,7 +60,7 @@ fn test_parser_app() {
|
|||
#[test]
|
||||
fn test_parser_unexpected_close() {
|
||||
assert_eq!(
|
||||
TypeDict::new().parse(">"),
|
||||
BimapTypeDict::new().parse(">"),
|
||||
Err(ParseError::UnexpectedClose)
|
||||
);
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ fn test_parser_unexpected_close() {
|
|||
#[test]
|
||||
fn test_parser_unexpected_token() {
|
||||
assert_eq!(
|
||||
TypeDict::new().parse("A B"),
|
||||
BimapTypeDict::new().parse("A B"),
|
||||
Err(ParseError::UnexpectedToken)
|
||||
);
|
||||
}
|
||||
|
@ -76,14 +76,14 @@ fn test_parser_unexpected_token() {
|
|||
#[test]
|
||||
fn test_parser_ladder() {
|
||||
assert_eq!(
|
||||
TypeDict::new().parse("A~B"),
|
||||
BimapTypeDict::new().parse("A~B"),
|
||||
Ok(TypeTerm::Ladder(vec![
|
||||
TypeTerm::TypeID(TypeID::Fun(0)),
|
||||
TypeTerm::TypeID(TypeID::Fun(1)),
|
||||
]))
|
||||
);
|
||||
assert_eq!(
|
||||
TypeDict::new().parse("A~B~C"),
|
||||
BimapTypeDict::new().parse("A~B~C"),
|
||||
Ok(TypeTerm::Ladder(vec![
|
||||
TypeTerm::TypeID(TypeID::Fun(0)),
|
||||
TypeTerm::TypeID(TypeID::Fun(1)),
|
||||
|
@ -95,7 +95,7 @@ fn test_parser_ladder() {
|
|||
#[test]
|
||||
fn test_parser_ladder_outside() {
|
||||
assert_eq!(
|
||||
TypeDict::new().parse("<A B>~C"),
|
||||
BimapTypeDict::new().parse("<A B>~C"),
|
||||
Ok(TypeTerm::Ladder(vec![
|
||||
TypeTerm::App(vec![
|
||||
TypeTerm::TypeID(TypeID::Fun(0)),
|
||||
|
@ -103,13 +103,13 @@ fn test_parser_ladder_outside() {
|
|||
]),
|
||||
TypeTerm::TypeID(TypeID::Fun(2)),
|
||||
]))
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parser_ladder_inside() {
|
||||
assert_eq!(
|
||||
TypeDict::new().parse("<A B~C>"),
|
||||
BimapTypeDict::new().parse("<A B~C>"),
|
||||
Ok(TypeTerm::App(vec![
|
||||
TypeTerm::TypeID(TypeID::Fun(0)),
|
||||
TypeTerm::Ladder(vec![
|
||||
|
@ -117,13 +117,13 @@ fn test_parser_ladder_inside() {
|
|||
TypeTerm::TypeID(TypeID::Fun(2)),
|
||||
])
|
||||
]))
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parser_ladder_between() {
|
||||
assert_eq!(
|
||||
TypeDict::new().parse("<A B~<C D>>"),
|
||||
BimapTypeDict::new().parse("<A B~<C D>>"),
|
||||
Ok(TypeTerm::App(vec![
|
||||
TypeTerm::TypeID(TypeID::Fun(0)),
|
||||
TypeTerm::Ladder(vec![
|
||||
|
@ -134,14 +134,14 @@ fn test_parser_ladder_between() {
|
|||
])
|
||||
])
|
||||
]))
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_parser_ladder_large() {
|
||||
assert_eq!(
|
||||
TypeDict::new().parse(
|
||||
BimapTypeDict::new().parse(
|
||||
"<Seq Date
|
||||
~<TimeSince UnixEpoch>
|
||||
~<Duration Seconds>
|
||||
|
@ -203,4 +203,3 @@ fn test_parser_ladder_large() {
|
|||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use crate::dict::TypeDict;
|
||||
use crate::{dict::BimapTypeDict, parser::*};
|
||||
|
||||
#[test]
|
||||
fn test_param_normalize() {
|
||||
let mut dict = TypeDict::new();
|
||||
let mut dict = BimapTypeDict::new();
|
||||
|
||||
assert_eq!(
|
||||
dict.parse("A~B~C").expect("parse error"),
|
||||
|
@ -56,4 +56,3 @@ fn test_param_normalize() {
|
|||
.param_normalize(),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
use {
|
||||
crate::{dict::*, term::*},
|
||||
crate::{dict::*, term::*, parser::*, unparser::*},
|
||||
std::iter::FromIterator
|
||||
};
|
||||
|
||||
|
@ -8,7 +8,7 @@ use {
|
|||
|
||||
#[test]
|
||||
fn test_subst() {
|
||||
let mut dict = TypeDict::new();
|
||||
let mut dict = BimapTypeDict::new();
|
||||
|
||||
let mut σ = std::collections::HashMap::new();
|
||||
|
||||
|
@ -29,4 +29,3 @@ fn test_subst() {
|
|||
dict.parse("<Seq ℕ~<Seq Char>>").unwrap()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use crate::dict::TypeDict;
|
||||
use crate::{dict::BimapTypeDict, parser::*, unparser::*};
|
||||
|
||||
#[test]
|
||||
fn test_semantic_subtype() {
|
||||
let mut dict = TypeDict::new();
|
||||
let mut dict = BimapTypeDict::new();
|
||||
|
||||
assert_eq!(
|
||||
dict.parse("A~B~C").expect("parse error")
|
||||
|
@ -19,11 +19,11 @@ fn test_semantic_subtype() {
|
|||
),
|
||||
Some((0, dict.parse("A~B1~C1").expect("parse errror")))
|
||||
);
|
||||
|
||||
|
||||
assert_eq!(
|
||||
dict.parse("A~B~C1").expect("parse error")
|
||||
.is_semantic_subtype_of(
|
||||
&dict.parse("B~C2").expect("parse errror")
|
||||
&dict.parse("B~C2").expect("parse errror")
|
||||
),
|
||||
Some((1, dict.parse("B~C1").expect("parse errror")))
|
||||
);
|
||||
|
@ -31,12 +31,12 @@ fn test_semantic_subtype() {
|
|||
|
||||
#[test]
|
||||
fn test_syntactic_subtype() {
|
||||
let mut dict = TypeDict::new();
|
||||
let mut dict = BimapTypeDict::new();
|
||||
|
||||
assert_eq!(
|
||||
dict.parse("A~B~C").expect("parse error")
|
||||
.is_syntactic_subtype_of(
|
||||
&dict.parse("A~B~C").expect("parse errror")
|
||||
&dict.parse("A~B~C").expect("parse errror")
|
||||
),
|
||||
Ok(0)
|
||||
);
|
||||
|
@ -44,7 +44,7 @@ fn test_syntactic_subtype() {
|
|||
assert_eq!(
|
||||
dict.parse("A~B~C").expect("parse error")
|
||||
.is_syntactic_subtype_of(
|
||||
&dict.parse("B~C").expect("parse errror")
|
||||
&dict.parse("B~C").expect("parse errror")
|
||||
),
|
||||
Ok(1)
|
||||
);
|
||||
|
@ -52,7 +52,7 @@ fn test_syntactic_subtype() {
|
|||
assert_eq!(
|
||||
dict.parse("A~B~C~D~E").expect("parse error")
|
||||
.is_syntactic_subtype_of(
|
||||
&dict.parse("C~D").expect("parse errror")
|
||||
&dict.parse("C~D").expect("parse errror")
|
||||
),
|
||||
Ok(2)
|
||||
);
|
||||
|
@ -60,7 +60,7 @@ fn test_syntactic_subtype() {
|
|||
assert_eq!(
|
||||
dict.parse("A~B~C~D~E").expect("parse error")
|
||||
.is_syntactic_subtype_of(
|
||||
&dict.parse("C~G").expect("parse errror")
|
||||
&dict.parse("C~G").expect("parse errror")
|
||||
),
|
||||
Err((2,3))
|
||||
);
|
||||
|
@ -68,7 +68,7 @@ fn test_syntactic_subtype() {
|
|||
assert_eq!(
|
||||
dict.parse("A~B~C~D~E").expect("parse error")
|
||||
.is_syntactic_subtype_of(
|
||||
&dict.parse("G~F~K").expect("parse errror")
|
||||
&dict.parse("G~F~K").expect("parse errror")
|
||||
),
|
||||
Err((0,0))
|
||||
);
|
||||
|
@ -94,4 +94,3 @@ fn test_syntactic_subtype() {
|
|||
Ok(4)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
|
||||
use {
|
||||
crate::{dict::*, term::*, unification::*},
|
||||
crate::{dict::*, parser::*, unparser::*, term::*, unification::*},
|
||||
std::iter::FromIterator
|
||||
};
|
||||
|
||||
//<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>\\
|
||||
|
||||
fn test_unify(ts1: &str, ts2: &str, expect_unificator: bool) {
|
||||
let mut dict = TypeDict::new();
|
||||
let mut dict = BimapTypeDict::new();
|
||||
dict.add_varname(String::from("T"));
|
||||
dict.add_varname(String::from("U"));
|
||||
dict.add_varname(String::from("V"));
|
||||
|
@ -33,7 +33,7 @@ fn test_unify(ts1: &str, ts2: &str, expect_unificator: bool) {
|
|||
|
||||
#[test]
|
||||
fn test_unification_error() {
|
||||
let mut dict = TypeDict::new();
|
||||
let mut dict = BimapTypeDict::new();
|
||||
dict.add_varname(String::from("T"));
|
||||
|
||||
assert_eq!(
|
||||
|
@ -89,7 +89,7 @@ fn test_unification() {
|
|||
true
|
||||
);
|
||||
|
||||
let mut dict = TypeDict::new();
|
||||
let mut dict = BimapTypeDict::new();
|
||||
|
||||
dict.add_varname(String::from("T"));
|
||||
dict.add_varname(String::from("U"));
|
||||
|
@ -129,10 +129,9 @@ fn test_unification() {
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_subtype_unification() {
|
||||
let mut dict = TypeDict::new();
|
||||
let mut dict = BimapTypeDict::new();
|
||||
|
||||
dict.add_varname(String::from("T"));
|
||||
dict.add_varname(String::from("U"));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue