add more subtype test-cases & fix normalize in case of normalizing sub-ladders
This commit is contained in:
parent
ccd60fc7bf
commit
3b944d15c8
2 changed files with 32 additions and 4 deletions
15
src/lnf.rs
15
src/lnf.rs
|
@ -31,7 +31,16 @@ impl TypeTerm {
|
||||||
match self {
|
match self {
|
||||||
TypeTerm::Ladder(args) => {
|
TypeTerm::Ladder(args) => {
|
||||||
for x in args.into_iter() {
|
for x in args.into_iter() {
|
||||||
new_ladder.push(x.normalize());
|
match x.normalize() {
|
||||||
|
TypeTerm::Ladder(gs) => {
|
||||||
|
for g in gs {
|
||||||
|
new_ladder.push(g);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g => {
|
||||||
|
new_ladder.push(g);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,9 +111,7 @@ impl TypeTerm {
|
||||||
TypeTerm::Ladder( v ) => {
|
TypeTerm::Ladder( v ) => {
|
||||||
v
|
v
|
||||||
},
|
},
|
||||||
_ => {
|
flat => vec![ flat ]
|
||||||
unreachable!();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,5 +72,26 @@ fn test_syntactic_subtype() {
|
||||||
),
|
),
|
||||||
Err(None)
|
Err(None)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
dict.parse("<Duration Seconds>~ℕ").expect("parse error")
|
||||||
|
.is_syntactic_subtype_of(
|
||||||
|
&dict.parse("ℕ").expect("parse errror")
|
||||||
|
),
|
||||||
|
Ok(1)
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
dict.parse("
|
||||||
|
<Duration Seconds>
|
||||||
|
~ℕ
|
||||||
|
~<PosInt 10 BigEndian>
|
||||||
|
~< Seq <Digit 10> ~ Char >"
|
||||||
|
).expect("parse error")
|
||||||
|
.is_syntactic_subtype_of(
|
||||||
|
&dict.parse("<Seq Char>").expect("parse errror")
|
||||||
|
),
|
||||||
|
Ok(4)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue