Skip to content

Commit

Permalink
one more logic test
Browse files Browse the repository at this point in the history
  • Loading branch information
dzhibas committed Feb 20, 2024
1 parent 3a2bbff commit db427cb
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions src/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,4 +331,57 @@ mod tests {
.unwrap()
);
}

#[test]
fn testing_logical_expression() {
assert_eq!(
true,
eval(
&parse("a=b and (c=d or e=f)").unwrap().1,
&HashMap::from([
("a", "b".into()),
("c", "non-exiting".into()),
("e", "f".into())
])
)
.unwrap()
);
assert_eq!(
true,
eval(
&parse("a=b and (c=d or e=f)").unwrap().1,
&HashMap::from([("a", "b".into()), ("c", "d".into()), ("e", "fnon".into())])
)
.unwrap()
);
assert_eq!(
true,
eval(
&parse("a=b and c=d or e=f").unwrap().1,
&HashMap::from([
("a", "non".into()),
("c", "non-exiting".into()),
("e", "f".into())
])
)
.unwrap()
);

assert_eq!(
true,
eval(
&parse("a=b and c=d or e=f").unwrap().1,
&HashMap::from([("a", "non".into()), ("c", "non".into()), ("e", "f".into())])
)
.unwrap()
);
assert_eq!(
false,
eval(
&parse("a=b and c=d or e=f").unwrap().1,
&HashMap::from([("a", "non".into()), ("c", "d".into()), ("e", "non".into())])
)
.unwrap()
);
}
}

0 comments on commit db427cb

Please sign in to comment.