Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch NOT propagation #482

Merged
merged 4 commits into from Oct 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions .circleci/config.yml
Expand Up @@ -54,9 +54,9 @@ jobs:
- run:
name: Run tests
command: ZOKRATES_HOME=$(pwd)/zokrates_stdlib/stdlib/ WITH_LIBSNARK=1 RUSTFLAGS="-D warnings" ./test.sh
- run:
name: Generate code coverage report
command: ./scripts/cov.sh
# - run:
# name: Generate code coverage report
# command: ./scripts/cov.sh
wasm_test:
docker:
- image: rustlang/rust:nightly-slim
Expand Down
27 changes: 26 additions & 1 deletion zokrates_core/src/static_analysis/propagation.rs
Expand Up @@ -418,7 +418,7 @@ impl<'ast, T: Field> Folder<'ast, T> for Propagator<'ast, T> {
let e = self.fold_boolean_expression(e);
match e {
BooleanExpression::Value(v) => BooleanExpression::Value(!v),
e => e,
e => BooleanExpression::Not(box e),
}
}
BooleanExpression::IfElse(box condition, box consequence, box alternative) => {
Expand Down Expand Up @@ -567,6 +567,31 @@ mod tests {
mod boolean {
use super::*;

#[test]
fn not() {
let e_true: BooleanExpression<FieldPrime> =
BooleanExpression::Not(box BooleanExpression::Value(false));

let e_false: BooleanExpression<FieldPrime> =
BooleanExpression::Not(box BooleanExpression::Value(true));

let e_default: BooleanExpression<FieldPrime> =
BooleanExpression::Not(box BooleanExpression::Identifier("a".into()));

assert_eq!(
Propagator::new().fold_boolean_expression(e_true),
BooleanExpression::Value(true)
);
assert_eq!(
Propagator::new().fold_boolean_expression(e_false),
BooleanExpression::Value(false)
);
assert_eq!(
Propagator::new().fold_boolean_expression(e_default.clone()),
e_default
);
}

#[test]
fn eq() {
let e_true = BooleanExpression::Eq(
Expand Down