mirror of
https://github.com/arnaucube/circom.git
synced 2026-02-06 18:56:40 +01:00
If added
This commit is contained in:
@@ -107,4 +107,26 @@ describe("basic cases", function () {
|
||||
]
|
||||
);
|
||||
});
|
||||
it("if unrolled", async () => {
|
||||
await doTest(
|
||||
"ifunrolled.circom",
|
||||
[
|
||||
[{in: 0}, {out: [1, 3, 6]}],
|
||||
[{in: 10}, {out: [11, 13, 16]}],
|
||||
[{in: __P__.minus(2)}, {out: [__P__.minus(1), 1, 4]}],
|
||||
]
|
||||
);
|
||||
});
|
||||
it("if rolled", async () => {
|
||||
await doTest(
|
||||
"ifrolled.circom",
|
||||
[
|
||||
[{in: 0}, {out: [1, 0, 0]}],
|
||||
[{in: 1}, {out: [0, 1, 0]}],
|
||||
[{in: 2}, {out: [0, 0, 1]}],
|
||||
[{in: 3}, {out: [0, 0, 0]}],
|
||||
[{in: __P__.minus(2)}, {out: [0,0,0]}],
|
||||
]
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
26
test/circuits/ifrolled.circom
Normal file
26
test/circuits/ifrolled.circom
Normal file
@@ -0,0 +1,26 @@
|
||||
template Main() {
|
||||
signal input in;
|
||||
signal output out[3];
|
||||
|
||||
if (in == 0) {
|
||||
out[0] <-- 1; // TRUE
|
||||
}
|
||||
if (in != 0) {
|
||||
out[0] <-- 0;
|
||||
}
|
||||
|
||||
if (in == 1) {
|
||||
out[1] <-- 1; // TRUE
|
||||
} else {
|
||||
out[1] <-- 0;
|
||||
}
|
||||
|
||||
if (in == 2) {
|
||||
out[2] <-- 1;
|
||||
} else {
|
||||
out[2] <-- 0; // TRUE
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
component main = Main();
|
||||
31
test/circuits/ifunrolled.circom
Normal file
31
test/circuits/ifunrolled.circom
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
|
||||
template Main() {
|
||||
signal input in;
|
||||
signal output out[3];
|
||||
|
||||
var c = 1;
|
||||
if (c == 1) {
|
||||
out[0] <== in +1; // TRUE
|
||||
}
|
||||
if (c == 0) {
|
||||
out[0] <== in +2;
|
||||
}
|
||||
|
||||
c = c +1;
|
||||
if (c == 2) {
|
||||
out[1] <== in + 3; // TRUE
|
||||
} else {
|
||||
out[1] <== in + 4;
|
||||
}
|
||||
|
||||
c = c +1;
|
||||
if (c == 2) {
|
||||
out[2] <== in + 5;
|
||||
} else {
|
||||
out[2] <== in + 6; // TRUE
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
component main = Main();
|
||||
Reference in New Issue
Block a user