more identity and inline tests
This commit is contained in:
parent
97b0cf6813
commit
dabaae8ca6
|
@ -1653,6 +1653,8 @@ mod tests {
|
|||
optimize::interner::CodeGenInterner,
|
||||
};
|
||||
|
||||
use super::NO_INLINE;
|
||||
|
||||
fn compare_optimization(
|
||||
mut expected: Program<Name>,
|
||||
mut program: Program<Name>,
|
||||
|
@ -1890,7 +1892,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn identity_reduce_0_occurrence() {
|
||||
fn identity_reduce_usage() {
|
||||
let program: Program<Name> = Program {
|
||||
version: (1, 0, 0),
|
||||
term: Term::sha2_256()
|
||||
|
@ -1912,6 +1914,29 @@ mod tests {
|
|||
compare_optimization(expected, program, |p| p.identity_reducer());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn identity_reduce_0_occurrence() {
|
||||
let program: Program<Name> = Program {
|
||||
version: (1, 0, 0),
|
||||
term: Term::sha2_256()
|
||||
.apply(Term::var("x"))
|
||||
.lambda("x")
|
||||
.apply(Term::byte_string(vec![]).delay())
|
||||
.lambda("identity")
|
||||
.apply(Term::var("y").lambda("y")),
|
||||
};
|
||||
|
||||
let expected = Program {
|
||||
version: (1, 0, 0),
|
||||
term: Term::sha2_256()
|
||||
.apply(Term::var("x"))
|
||||
.lambda("x")
|
||||
.apply(Term::byte_string(vec![]).delay()),
|
||||
};
|
||||
|
||||
compare_optimization(expected, program, |p| p.identity_reducer());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn identity_reduce_param() {
|
||||
let program: Program<Name> = Program {
|
||||
|
@ -1959,6 +1984,29 @@ mod tests {
|
|||
compare_optimization(expected, program, |p| p.identity_reducer());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn identity_reduce_no_inline() {
|
||||
let program: Program<Name> = Program {
|
||||
version: (1, 0, 0),
|
||||
term: Term::sha2_256()
|
||||
.apply(Term::var("identity").apply(Term::var("x")))
|
||||
.lambda("x")
|
||||
.apply(Term::byte_string(vec![]).delay())
|
||||
.lambda("identity")
|
||||
.apply(Term::var("y").lambda("y").lambda(NO_INLINE)),
|
||||
};
|
||||
|
||||
let expected = Program {
|
||||
version: (1, 0, 0),
|
||||
term: Term::sha2_256()
|
||||
.apply(Term::var("x"))
|
||||
.lambda("x")
|
||||
.apply(Term::byte_string(vec![]).delay()),
|
||||
};
|
||||
|
||||
compare_optimization(expected, program, |p| p.identity_reducer());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn inline_reduce_delay_sha() {
|
||||
let program: Program<Name> = Program {
|
||||
|
@ -1977,6 +2025,23 @@ mod tests {
|
|||
compare_optimization(expected, program, |p| p.inline_reducer());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn inline_reduce_0_occurrence() {
|
||||
let program: Program<Name> = Program {
|
||||
version: (1, 0, 0),
|
||||
term: Term::sha2_256()
|
||||
.lambda("x")
|
||||
.apply(Term::byte_string(vec![]).delay()),
|
||||
};
|
||||
|
||||
let expected = Program {
|
||||
version: (1, 0, 0),
|
||||
term: Term::sha2_256(),
|
||||
};
|
||||
|
||||
compare_optimization(expected, program, |p| p.inline_reducer());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn wrap_data_reduce_i_data() {
|
||||
let program: Program<Name> = Program {
|
||||
|
|
Loading…
Reference in New Issue