Skip to content

Commit

Permalink
Merge pull request #482 from Zokrates/patch-not-propagation
Browse files Browse the repository at this point in the history
Patch NOT propagation
  • Loading branch information
stefandeml committed Oct 1, 2019
2 parents 542c4c1 + 3dd5783 commit 478e08a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
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

0 comments on commit 478e08a

Please sign in to comment.