diff --git a/compiler/src/function/input/main_function_input.rs b/compiler/src/function/input/main_function_input.rs index 21fbabfe87..13ce4b9e5a 100644 --- a/compiler/src/function/input/main_function_input.rs +++ b/compiler/src/function/input/main_function_input.rs @@ -120,7 +120,10 @@ impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { Ok(ConstrainedValue::Tuple( values .iter() - .map(|x| self.constant_main_function_input(cs, type_, name, Some(x.clone()), span)) + .enumerate() + .map(|(i, x)| { + self.constant_main_function_input(cs, types.get(i).unwrap(), name, Some(x.clone()), span) + }) .collect::, _>>()?, )) } diff --git a/tests/compiler/_field/add.leo b/tests/compiler/_field/add.leo deleted file mode 100644 index 8dc2c7df4e..0000000000 --- a/tests/compiler/_field/add.leo +++ /dev/null @@ -1,3 +0,0 @@ -function main(a: field, b: field, c: field) { - console.assert(a + b == c); -} \ No newline at end of file diff --git a/tests/compiler/_field/console_assert.leo b/tests/compiler/_field/console_assert.leo deleted file mode 100644 index c7224bcea5..0000000000 --- a/tests/compiler/_field/console_assert.leo +++ /dev/null @@ -1,3 +0,0 @@ -function main(a: field, b: field) { - console.assert(a == b); -} \ No newline at end of file diff --git a/tests/compiler/_field/div.leo b/tests/compiler/_field/div.leo deleted file mode 100644 index 028b06fad2..0000000000 --- a/tests/compiler/_field/div.leo +++ /dev/null @@ -1,3 +0,0 @@ -function main(a: field, b: field, c: field) { - console.assert(a / b == c); -} \ No newline at end of file diff --git a/tests/compiler/_field/eq.leo b/tests/compiler/_field/eq.leo deleted file mode 100644 index e64307d8de..0000000000 --- a/tests/compiler/_field/eq.leo +++ /dev/null @@ -1,3 +0,0 @@ -function main(a: field, b: field, c: bool) { - console.assert(a == b == c); -} \ No newline at end of file diff --git a/tests/compiler/_field/field.leo b/tests/compiler/_field/field.leo deleted file mode 100644 index 5d5732e906..0000000000 --- a/tests/compiler/_field/field.leo +++ /dev/null @@ -1,4 +0,0 @@ -function main() { - const negOneField: field = -1field; - const oneField = 1field; -} \ No newline at end of file diff --git a/tests/compiler/_field/mul.leo b/tests/compiler/_field/mul.leo deleted file mode 100644 index 7df7c83830..0000000000 --- a/tests/compiler/_field/mul.leo +++ /dev/null @@ -1,3 +0,0 @@ -function main(a: field, b: field, c: field) { - console.assert(a * b == c); -} \ No newline at end of file diff --git a/tests/compiler/_field/negate.leo b/tests/compiler/_field/negate.leo deleted file mode 100644 index 94c730207a..0000000000 --- a/tests/compiler/_field/negate.leo +++ /dev/null @@ -1,3 +0,0 @@ -function main(a: field, b: field) { - console.assert(-a == b); -} \ No newline at end of file diff --git a/tests/compiler/_field/no_space_between_literal.leo b/tests/compiler/_field/no_space_between_literal.leo deleted file mode 100644 index 9ac9dcd5db..0000000000 --- a/tests/compiler/_field/no_space_between_literal.leo +++ /dev/null @@ -1,3 +0,0 @@ -function main() { - const f = 1 field; -} \ No newline at end of file diff --git a/tests/compiler/_field/output_register.leo b/tests/compiler/_field/output_register.leo deleted file mode 100644 index e27a3947bd..0000000000 --- a/tests/compiler/_field/output_register.leo +++ /dev/null @@ -1,3 +0,0 @@ -function main(registers) -> field { - return registers.r; -} \ No newline at end of file diff --git a/tests/compiler/_field/sub.leo b/tests/compiler/_field/sub.leo deleted file mode 100644 index 2c84b24647..0000000000 --- a/tests/compiler/_field/sub.leo +++ /dev/null @@ -1,3 +0,0 @@ -function main(a: field, b: field, c: field) { - console.assert(a - b == c); -} \ No newline at end of file diff --git a/tests/compiler/_field/ternary.leo b/tests/compiler/_field/ternary.leo deleted file mode 100644 index 05cb161b46..0000000000 --- a/tests/compiler/_field/ternary.leo +++ /dev/null @@ -1,5 +0,0 @@ -function main(s: bool, a: field, b: field, c: field) { - const r = s ? a : b; - - console.assert(r == c); -} \ No newline at end of file diff --git a/tests/compiler/char/circuit.leo b/tests/compiler/char/circuit.leo index 545cb026b2..7bdcd1119f 100644 --- a/tests/compiler/char/circuit.leo +++ b/tests/compiler/char/circuit.leo @@ -16,6 +16,6 @@ circuit Foo { function main(character: char) -> char { let f = Foo { character }; - let character = f.character == 'a' ? 'a' : 'Z'; + let character = f.character == 'a' ? 'a' : f.character; return character; } \ No newline at end of file diff --git a/tests/compiler/char/neq.leo b/tests/compiler/char/neq.leo new file mode 100644 index 0000000000..5605ce31b4 --- /dev/null +++ b/tests/compiler/char/neq.leo @@ -0,0 +1,14 @@ +/* +namespace: Compile +expectation: Pass +input_file: + - inputs/ascii.in + - inputs/escaped_unicode.in + - inputs/escaped.in + - inputs/hex.in + - inputs/unicode.in +*/ + +function main(character: char) -> char { + return character != 'a' ? 'a' : 'Z'; +} \ No newline at end of file diff --git a/tests/compiler/char/output/output_char.out b/tests/compiler/char/output/output_char.out index 8c5c6ba182..323925e081 100644 --- a/tests/compiler/char/output/output_char.out +++ b/tests/compiler/char/output/output_char.out @@ -1,2 +1,2 @@ [registers] -r: char = a; +r: char = 'a'; diff --git a/tests/compiler/core/blake2s.leo b/tests/compiler/core/blake2s.leo index 8286c68fdd..2786313eba 100644 --- a/tests/compiler/core/blake2s.leo +++ b/tests/compiler/core/blake2s.leo @@ -1,9 +1,7 @@ -/* -namespace: Compile -expectation: Fail -input_files: - - input/dummy.in -*/ +// namespace: Compile +// expectation: Fail +// input_files: +// - input/dummy.in import core.unstable.blake2s.BadCircuit; // `BadCircuit` is not included in the blake2s package diff --git a/tests/compiler/core/unstable_blake2s.leo b/tests/compiler/core/unstable_blake2s.leo index 1229f457c4..6776d8a6ea 100644 --- a/tests/compiler/core/unstable_blake2s.leo +++ b/tests/compiler/core/unstable_blake2s.leo @@ -1,14 +1,12 @@ -/* -namespace: Compile -expectation: Pass -inputs: - - blake.in: | - [main] - message: [u8; 32] = [0; 32]; +// namespace: Compile +// expectation: Pass +// inputs: +// - blake.in: | +// [main] +// message: [u8; 32] = [0; 32]; - [registers] - r0: [u8; 32] = [0; 32]; -*/ +// [registers] +// r0: [u8; 32] = [0; 32]; import core.unstable.blake2s.Blake2s; diff --git a/tests/compiler/field/add.leo b/tests/compiler/field/add.leo new file mode 100644 index 0000000000..72633674a0 --- /dev/null +++ b/tests/compiler/field/add.leo @@ -0,0 +1,10 @@ +/* +namespace: Compile +expectation: Pass +input_file: + - inputs/fields.in +*/ + +function main(a: field, b: field, c: field) -> bool { + return a + b == c; +} \ No newline at end of file diff --git a/tests/compiler/field/div.leo b/tests/compiler/field/div.leo new file mode 100644 index 0000000000..4121623d52 --- /dev/null +++ b/tests/compiler/field/div.leo @@ -0,0 +1,10 @@ +/* +namespace: Compile +expectation: Pass +input_file: + - inputs/fields.in +*/ + +function main(a: field, b: field, c: field) -> bool { + return a / b != c; +} \ No newline at end of file diff --git a/tests/compiler/field/eq.leo b/tests/compiler/field/eq.leo new file mode 100644 index 0000000000..eed7a98757 --- /dev/null +++ b/tests/compiler/field/eq.leo @@ -0,0 +1,10 @@ +/* +namespace: Compile +expectation: Pass +input_file: + - inputs/fields.in +*/ + +function main(a: field, b: field) -> bool { + return a == b; +} \ No newline at end of file diff --git a/tests/compiler/field/field.leo b/tests/compiler/field/field.leo new file mode 100644 index 0000000000..89f6d7f84b --- /dev/null +++ b/tests/compiler/field/field.leo @@ -0,0 +1,11 @@ +/* +namespace: Compile +expectation: Pass +input_file: + - inputs/fields.in +*/ + +function main(a: field) -> bool { + const negOneField: field = -1field; + return negOneField + a == 0field; +} \ No newline at end of file diff --git a/tests/compiler/field/inputs/fields.in b/tests/compiler/field/inputs/fields.in new file mode 100644 index 0000000000..8fed43e1cf --- /dev/null +++ b/tests/compiler/field/inputs/fields.in @@ -0,0 +1,7 @@ +[main] +a: field = 1field; +b: field = 1field; +c: field = 2field; + +[registers] +r: bool = false; \ No newline at end of file diff --git a/tests/compiler/_field/input/register_one.in b/tests/compiler/field/inputs/register_one.in similarity index 100% rename from tests/compiler/_field/input/register_one.in rename to tests/compiler/field/inputs/register_one.in diff --git a/tests/compiler/_field/input/register_zero.in b/tests/compiler/field/inputs/register_zero.in similarity index 100% rename from tests/compiler/_field/input/register_zero.in rename to tests/compiler/field/inputs/register_zero.in diff --git a/tests/compiler/field/mul.leo b/tests/compiler/field/mul.leo new file mode 100644 index 0000000000..26dcaf37f4 --- /dev/null +++ b/tests/compiler/field/mul.leo @@ -0,0 +1,10 @@ +/* +namespace: Compile +expectation: Pass +input_file: + - inputs/fields.in +*/ + +function main(a: field, b: field, c: field) -> bool { + return a * b == c; +} \ No newline at end of file diff --git a/tests/compiler/field/negate.leo b/tests/compiler/field/negate.leo new file mode 100644 index 0000000000..badf9c3da6 --- /dev/null +++ b/tests/compiler/field/negate.leo @@ -0,0 +1,10 @@ +/* +namespace: Compile +expectation: Pass +input_file: + - inputs/fields.in +*/ + +function main(a: field, b: field) -> bool { + return -a == -b; +} \ No newline at end of file diff --git a/tests/compiler/field/no_space_between_literal.leo b/tests/compiler/field/no_space_between_literal.leo new file mode 100644 index 0000000000..4f93b287be --- /dev/null +++ b/tests/compiler/field/no_space_between_literal.leo @@ -0,0 +1,8 @@ +/* +namespace: Compile +expectation: Fail +*/ + +function main() { + const f = 1 field; +} \ No newline at end of file diff --git a/tests/compiler/_field/output/register_one.out b/tests/compiler/field/output/register_one.out similarity index 100% rename from tests/compiler/_field/output/register_one.out rename to tests/compiler/field/output/register_one.out diff --git a/tests/compiler/_field/output/register_zero.out b/tests/compiler/field/output/register_zero.out similarity index 100% rename from tests/compiler/_field/output/register_zero.out rename to tests/compiler/field/output/register_zero.out diff --git a/tests/compiler/field/sub.leo b/tests/compiler/field/sub.leo new file mode 100644 index 0000000000..fe11701161 --- /dev/null +++ b/tests/compiler/field/sub.leo @@ -0,0 +1,3 @@ +function main(a: field, b: field, c: field) -> bool { + return a - b == c; +} \ No newline at end of file diff --git a/tests/compiler/field/ternary.leo b/tests/compiler/field/ternary.leo new file mode 100644 index 0000000000..980b878248 --- /dev/null +++ b/tests/compiler/field/ternary.leo @@ -0,0 +1,3 @@ +function main(a: field, b: field, c: field) -> bool { + return b == 1field ? a == 1field : c == 2field; +} \ No newline at end of file diff --git a/tests/expectations/compiler/compiler/char/circuit.leo.out b/tests/expectations/compiler/compiler/char/circuit.leo.out index aaffccc60a..9a578e2249 100644 --- a/tests/expectations/compiler/compiler/char/circuit.leo.out +++ b/tests/expectations/compiler/compiler/char/circuit.leo.out @@ -1,5 +1,42 @@ --- namespace: Compile -expectation: Fail +expectation: Pass outputs: - - "- Circuit has no constraints, use inputs and registers in program to produce them" + - circuit: + num_public_variables: 0 + num_private_variables: 6 + num_constraints: 4 + at: 2859fe6f24016b5634df2791da7de932e68ec32c73b5b573e0c39e968c7a4e12 + bt: 8143508f19c8eee208a7fbbcfb833aeeace6ba0a761e41d028599d2237cc60fa + ct: d0c6feeed1e6b8d5c0e03dc9e25641b7fdc34ad912e2b1488296d4a99ed6cbf5 + output: + - input_file: inputs/ascii.in + output: + registers: + r: + type: char + value: a + - input_file: inputs/escaped_unicode.in + output: + registers: + r: + type: char + value: ❤ + - input_file: inputs/escaped.in + output: + registers: + r: + type: char + value: "'" + - input_file: inputs/hex.in + output: + registers: + r: + type: char + value: "\n" + - input_file: inputs/unicode.in + output: + registers: + r: + type: char + value: ❤ diff --git a/tests/expectations/compiler/compiler/char/neq.leo.out b/tests/expectations/compiler/compiler/char/neq.leo.out new file mode 100644 index 0000000000..48f1729114 --- /dev/null +++ b/tests/expectations/compiler/compiler/char/neq.leo.out @@ -0,0 +1,42 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 6 + num_constraints: 3 + at: cc1286e0b6fa2e90fb6f0880431a7c1e2cc37a329fae3aff1c13f51036c66f12 + bt: 02c492cb6df07172e56cffd0cfd902a8443921e1256a2d907bbabd30bf6b8f6d + ct: a1f8e2b168c0f2f28f0ca3f16ce9b25ba7f7c410cfd68b0912bf19c90b53f2a2 + output: + - input_file: inputs/ascii.in + output: + registers: + r: + type: char + value: Z + - input_file: inputs/escaped_unicode.in + output: + registers: + r: + type: char + value: a + - input_file: inputs/escaped.in + output: + registers: + r: + type: char + value: a + - input_file: inputs/hex.in + output: + registers: + r: + type: char + value: a + - input_file: inputs/unicode.in + output: + registers: + r: + type: char + value: a diff --git a/tests/expectations/compiler/compiler/core/blake2s.leo.out b/tests/expectations/compiler/compiler/core/blake2s.leo.out deleted file mode 100644 index 07c482845a..0000000000 --- a/tests/expectations/compiler/compiler/core/blake2s.leo.out +++ /dev/null @@ -1,5 +0,0 @@ ---- -namespace: Compile -expectation: Fail -outputs: - - " --> compiler-test:3:30\n |\n 3 | import core.unstable.blake2s.BadCircuit; // `BadCircuit` is not included in the blake2s package\n | ^^^^^^^^^^\n |\n = failed to resolve import: 'core.unstable.blake2s.BadCircuit'" diff --git a/tests/expectations/compiler/compiler/core/unstable_blake2s.leo.out b/tests/expectations/compiler/compiler/core/unstable_blake2s.leo.out deleted file mode 100644 index 32b64e0840..0000000000 --- a/tests/expectations/compiler/compiler/core/unstable_blake2s.leo.out +++ /dev/null @@ -1,18 +0,0 @@ ---- -namespace: Compile -expectation: Pass -outputs: - - circuit: - num_public_variables: 0 - num_private_variables: 20168 - num_constraints: 20472 - at: 43b5f7bd5efbf13ae0684e3c506e5e28866ce7a29f5d6b1442925913bb07a73b - bt: 4d435c1eac471fb7b40b0d83503e2aa13f49db68fc71d64be84ddc9cb053a15d - ct: 081e529f5d26cb4cea2d8288ad454a8d0b381f2fb81e0bd21b47d4186777504f - output: - - input_file: blake.in - output: - registers: - r0: - type: "[u8; 32]" - value: "[213, 24, 235, 180, 216, 116, 28, 65, 88, 162, 204, 6, 23, 8, 66, 112, 214, 239, 242, 134, 165, 39, 172, 247, 65, 130, 155, 2, 97, 147, 14, 57]" diff --git a/tests/expectations/compiler/compiler/field/add.leo.out b/tests/expectations/compiler/compiler/field/add.leo.out new file mode 100644 index 0000000000..b2d25bf815 --- /dev/null +++ b/tests/expectations/compiler/compiler/field/add.leo.out @@ -0,0 +1,18 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 5 + num_constraints: 3 + at: 58e404664f2d64d2fd5fee64bf6e997f542a822b8b17e394fcdd7bed05386db8 + bt: f91b8601243dbd0d25e7df8f34ff304ca78a295fdfafbe0102ec6ce4fcb3c0f0 + ct: fe68b86a12c0b8c1585a656d7c4b8c47fbe19677b5da7ce0aae1d80dffb2a2ca + output: + - input_file: inputs/fields.in + output: + registers: + r: + type: bool + value: "true" diff --git a/tests/expectations/compiler/compiler/field/div.leo.out b/tests/expectations/compiler/compiler/field/div.leo.out new file mode 100644 index 0000000000..49a15b380a --- /dev/null +++ b/tests/expectations/compiler/compiler/field/div.leo.out @@ -0,0 +1,18 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 7 + num_constraints: 5 + at: 545f3730dcbdb3a3dff41db4263dd41f9be9cf279fdc3cde9518973db0c88685 + bt: 0a5ae5a6be6351f852bbcc193e57320be38fff279cf6fd65a3239c3a64239b27 + ct: f25b05da849d0d7fcaab89d41d9624efacb48b7ba983f73a0d5f383b16f7009b + output: + - input_file: inputs/fields.in + output: + registers: + r: + type: bool + value: "true" diff --git a/tests/expectations/compiler/compiler/field/eq.leo.out b/tests/expectations/compiler/compiler/field/eq.leo.out new file mode 100644 index 0000000000..9dcbe87829 --- /dev/null +++ b/tests/expectations/compiler/compiler/field/eq.leo.out @@ -0,0 +1,18 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 4 + num_constraints: 3 + at: ca775a363045cd405dd1d60cd10edb6cc6e4c0b164934951dab0977509b8225c + bt: 02c492cb6df07172e56cffd0cfd902a8443921e1256a2d907bbabd30bf6b8f6d + ct: a1f8e2b168c0f2f28f0ca3f16ce9b25ba7f7c410cfd68b0912bf19c90b53f2a2 + output: + - input_file: inputs/fields.in + output: + registers: + r: + type: bool + value: "true" diff --git a/tests/expectations/compiler/compiler/field/field.leo.out b/tests/expectations/compiler/compiler/field/field.leo.out new file mode 100644 index 0000000000..f7461da86f --- /dev/null +++ b/tests/expectations/compiler/compiler/field/field.leo.out @@ -0,0 +1,18 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 4 + num_constraints: 3 + at: cfcc3adf871aef0910034c4c3478746733a9746d44fd678971ee2e1e5e69dffd + bt: 02c492cb6df07172e56cffd0cfd902a8443921e1256a2d907bbabd30bf6b8f6d + ct: a1f8e2b168c0f2f28f0ca3f16ce9b25ba7f7c410cfd68b0912bf19c90b53f2a2 + output: + - input_file: inputs/fields.in + output: + registers: + r: + type: bool + value: "true" diff --git a/tests/expectations/compiler/compiler/field/mul.leo.out b/tests/expectations/compiler/compiler/field/mul.leo.out new file mode 100644 index 0000000000..6c7beec523 --- /dev/null +++ b/tests/expectations/compiler/compiler/field/mul.leo.out @@ -0,0 +1,18 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 6 + num_constraints: 4 + at: 7dcea624bdc7a6e6fb5f5e93395e84a96db66898779eb3f5595c4e30e3684f17 + bt: c21a8e9f463d2fad68fd3a88904dd88f2a3dc7dcb01835357fa4ee457ef1673b + ct: 4b4ef106804964b8a1ee7c1dad3d4682d20a0d07f576130bfec9989b353bf596 + output: + - input_file: inputs/fields.in + output: + registers: + r: + type: bool + value: "false" diff --git a/tests/expectations/compiler/compiler/field/negate.leo.out b/tests/expectations/compiler/compiler/field/negate.leo.out new file mode 100644 index 0000000000..eb7c04c512 --- /dev/null +++ b/tests/expectations/compiler/compiler/field/negate.leo.out @@ -0,0 +1,18 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 4 + num_constraints: 3 + at: cc1286e0b6fa2e90fb6f0880431a7c1e2cc37a329fae3aff1c13f51036c66f12 + bt: 02c492cb6df07172e56cffd0cfd902a8443921e1256a2d907bbabd30bf6b8f6d + ct: a1f8e2b168c0f2f28f0ca3f16ce9b25ba7f7c410cfd68b0912bf19c90b53f2a2 + output: + - input_file: inputs/fields.in + output: + registers: + r: + type: bool + value: "true" diff --git a/tests/expectations/compiler/compiler/field/no_space_between_literal.leo.out b/tests/expectations/compiler/compiler/field/no_space_between_literal.leo.out new file mode 100644 index 0000000000..ad72f642e2 --- /dev/null +++ b/tests/expectations/compiler/compiler/field/no_space_between_literal.leo.out @@ -0,0 +1,5 @@ +--- +namespace: Compile +expectation: Fail +outputs: + - " --> compiler-test:4:13\n |\n 4 | const f = 1 field;\n | ^\n |\n = Unexpected white space between terms 1 and field"