mirror of
https://github.com/AleoHQ/leo.git
synced 2024-12-03 01:16:16 +03:00
tests are passing interestingly but idk if they should be, == doesn't work for input on fields
This commit is contained in:
commit
b6479b754f
@ -120,7 +120,10 @@ impl<'a, F: PrimeField, G: GroupType<F>> 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::<Result<Vec<_>, _>>()?,
|
||||
))
|
||||
}
|
||||
|
@ -1,3 +0,0 @@
|
||||
function main(a: field, b: field, c: field) {
|
||||
console.assert(a + b == c);
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
function main(a: field, b: field) {
|
||||
console.assert(a == b);
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
function main(a: field, b: field, c: field) {
|
||||
console.assert(a / b == c);
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
function main(a: field, b: field, c: bool) {
|
||||
console.assert(a == b == c);
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
function main() {
|
||||
const negOneField: field = -1field;
|
||||
const oneField = 1field;
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
function main(a: field, b: field, c: field) {
|
||||
console.assert(a * b == c);
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
function main(a: field, b: field) {
|
||||
console.assert(-a == b);
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
function main() {
|
||||
const f = 1 field;
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
function main(registers) -> field {
|
||||
return registers.r;
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
function main(a: field, b: field, c: field) {
|
||||
console.assert(a - b == c);
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
function main(s: bool, a: field, b: field, c: field) {
|
||||
const r = s ? a : b;
|
||||
|
||||
console.assert(r == c);
|
||||
}
|
@ -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;
|
||||
}
|
14
tests/compiler/char/neq.leo
Normal file
14
tests/compiler/char/neq.leo
Normal file
@ -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';
|
||||
}
|
@ -1,2 +1,2 @@
|
||||
[registers]
|
||||
r: char = a;
|
||||
r: char = 'a';
|
||||
|
@ -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
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
10
tests/compiler/field/add.leo
Normal file
10
tests/compiler/field/add.leo
Normal file
@ -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;
|
||||
}
|
10
tests/compiler/field/div.leo
Normal file
10
tests/compiler/field/div.leo
Normal file
@ -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;
|
||||
}
|
10
tests/compiler/field/eq.leo
Normal file
10
tests/compiler/field/eq.leo
Normal file
@ -0,0 +1,10 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file:
|
||||
- inputs/fields.in
|
||||
*/
|
||||
|
||||
function main(a: field, b: field) -> bool {
|
||||
return a == b;
|
||||
}
|
11
tests/compiler/field/field.leo
Normal file
11
tests/compiler/field/field.leo
Normal file
@ -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;
|
||||
}
|
7
tests/compiler/field/inputs/fields.in
Normal file
7
tests/compiler/field/inputs/fields.in
Normal file
@ -0,0 +1,7 @@
|
||||
[main]
|
||||
a: field = 1field;
|
||||
b: field = 1field;
|
||||
c: field = 2field;
|
||||
|
||||
[registers]
|
||||
r: bool = false;
|
10
tests/compiler/field/mul.leo
Normal file
10
tests/compiler/field/mul.leo
Normal file
@ -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;
|
||||
}
|
10
tests/compiler/field/negate.leo
Normal file
10
tests/compiler/field/negate.leo
Normal file
@ -0,0 +1,10 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file:
|
||||
- inputs/fields.in
|
||||
*/
|
||||
|
||||
function main(a: field, b: field) -> bool {
|
||||
return -a == -b;
|
||||
}
|
8
tests/compiler/field/no_space_between_literal.leo
Normal file
8
tests/compiler/field/no_space_between_literal.leo
Normal file
@ -0,0 +1,8 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
*/
|
||||
|
||||
function main() {
|
||||
const f = 1 field;
|
||||
}
|
3
tests/compiler/field/sub.leo
Normal file
3
tests/compiler/field/sub.leo
Normal file
@ -0,0 +1,3 @@
|
||||
function main(a: field, b: field, c: field) -> bool {
|
||||
return a - b == c;
|
||||
}
|
3
tests/compiler/field/ternary.leo
Normal file
3
tests/compiler/field/ternary.leo
Normal file
@ -0,0 +1,3 @@
|
||||
function main(a: field, b: field, c: field) -> bool {
|
||||
return b == 1field ? a == 1field : c == 2field;
|
||||
}
|
@ -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: ❤
|
||||
|
42
tests/expectations/compiler/compiler/char/neq.leo.out
Normal file
42
tests/expectations/compiler/compiler/char/neq.leo.out
Normal file
@ -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
|
@ -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'"
|
@ -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]"
|
18
tests/expectations/compiler/compiler/field/add.leo.out
Normal file
18
tests/expectations/compiler/compiler/field/add.leo.out
Normal file
@ -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"
|
18
tests/expectations/compiler/compiler/field/div.leo.out
Normal file
18
tests/expectations/compiler/compiler/field/div.leo.out
Normal file
@ -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"
|
18
tests/expectations/compiler/compiler/field/eq.leo.out
Normal file
18
tests/expectations/compiler/compiler/field/eq.leo.out
Normal file
@ -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"
|
18
tests/expectations/compiler/compiler/field/field.leo.out
Normal file
18
tests/expectations/compiler/compiler/field/field.leo.out
Normal file
@ -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"
|
18
tests/expectations/compiler/compiler/field/mul.leo.out
Normal file
18
tests/expectations/compiler/compiler/field/mul.leo.out
Normal file
@ -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"
|
18
tests/expectations/compiler/compiler/field/negate.leo.out
Normal file
18
tests/expectations/compiler/compiler/field/negate.leo.out
Normal file
@ -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"
|
@ -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"
|
Loading…
Reference in New Issue
Block a user