mirror of
https://github.com/AleoHQ/leo.git
synced 2024-12-01 10:17:30 +03:00
test conflicts + clippy
This commit is contained in:
parent
6bb14425fd
commit
ac57fe6410
@ -44,20 +44,26 @@ pub struct Output {
|
||||
|
||||
impl fmt::Display for Output {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "[{}]\n", REGISTERS_VARIABLE_NAME)?;
|
||||
writeln!(f, "[{}]", REGISTERS_VARIABLE_NAME)?;
|
||||
// format: "token_id: u64 = 1u64;"
|
||||
for (name, register) in self.registers.iter() {
|
||||
write!(f, "{}: {} = {};\n", name, register.type_, register.value)?;
|
||||
writeln!(f, "{}: {} = {};", name, register.type_, register.value)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<OutputBytes> for Output {
|
||||
fn into(self) -> OutputBytes {
|
||||
OutputBytes::from(self.to_string().into_bytes())
|
||||
}
|
||||
}
|
||||
// impl Into<OutputBytes> for Output {
|
||||
// fn into(self) -> OutputBytes {
|
||||
// OutputBytes::from(self.to_string().into_bytes())
|
||||
// }
|
||||
// }
|
||||
|
||||
// impl From<Output> for OutputBytes {
|
||||
// fn from(a: Output) -> Self {
|
||||
|
||||
// }
|
||||
// }
|
||||
|
||||
impl Output {
|
||||
pub fn new<'a, F: PrimeField, G: GroupType<F>>(
|
||||
|
@ -314,8 +314,9 @@ impl ParserContext {
|
||||
pub fn parse_definition_statement(&mut self) -> SyntaxResult<DefinitionStatement> {
|
||||
let declare = self.expect_oneof(&[Token::Let, Token::Const])?;
|
||||
let mut variable_names = Vec::new();
|
||||
variable_names.push(self.parse_variable_name(&declare)?);
|
||||
|
||||
if self.eat(Token::LeftParen).is_some() {
|
||||
variable_names.push(self.parse_variable_name(&declare)?);
|
||||
let mut eaten_ending = false;
|
||||
while self.eat(Token::Comma).is_some() {
|
||||
if self.eat(Token::RightParen).is_some() {
|
||||
@ -327,8 +328,6 @@ impl ParserContext {
|
||||
if !eaten_ending {
|
||||
self.expect(Token::RightParen)?;
|
||||
}
|
||||
} else {
|
||||
variable_names.push(self.parse_variable_name(&declare)?);
|
||||
}
|
||||
|
||||
let type_ = if self.eat(Token::Colon).is_some() {
|
||||
|
@ -16,12 +16,12 @@ circuit Foo {
|
||||
|
||||
circuit Bar {
|
||||
function bar(a: u32) -> u32 {
|
||||
const f = Foo { a: a };
|
||||
let f = Foo { a: a };
|
||||
return f.a;
|
||||
}
|
||||
}
|
||||
|
||||
function main(a: u32) -> bool {
|
||||
const b = Bar::bar(a);
|
||||
let b = Bar::bar(a);
|
||||
return a == b;
|
||||
}
|
||||
|
@ -15,6 +15,6 @@ circuit Foo {
|
||||
}
|
||||
|
||||
function main(x: u32) -> u32 {
|
||||
const a = Foo { x: x };
|
||||
let a = Foo { x: x };
|
||||
return a.x;
|
||||
}
|
||||
|
@ -4,6 +4,9 @@ expectation: Pass
|
||||
inputs:
|
||||
- inline.in: |
|
||||
[main]
|
||||
y: bool = true;
|
||||
|
||||
[constants]
|
||||
x: u8 = 10;
|
||||
|
||||
[registers]
|
||||
@ -18,9 +21,9 @@ circuit Foo {
|
||||
}
|
||||
}
|
||||
|
||||
function main(x: u8) -> bool {
|
||||
function main(const x: u8, y: bool) -> bool {
|
||||
const a = Foo { x };
|
||||
const b = Foo::new(x);
|
||||
|
||||
return b.x == a.x;
|
||||
return b.x == a.x == y;
|
||||
}
|
||||
|
@ -23,8 +23,8 @@ circuit Foo {
|
||||
}
|
||||
|
||||
function main(x: u32) -> bool {
|
||||
const a = Foo { x };
|
||||
const b = a.add_x(1u32);
|
||||
let a = Foo { x };
|
||||
let b = a.add_x(1u32);
|
||||
|
||||
return b == x + 1;
|
||||
}
|
||||
|
@ -17,10 +17,10 @@ circuit PedersenHash {
|
||||
return Self { parameters: parameters };
|
||||
}
|
||||
|
||||
function hash(self, bits: [bool; 512]) -> u32 {
|
||||
function hash(const self, bits: [bool; 512]) -> u32 {
|
||||
let digest: u32 = 0;
|
||||
for i in 0..512 {
|
||||
const base = bits[i] ? self.parameters[i] : 0u32;
|
||||
let base = bits[i] ? self.parameters[i] : 0u32;
|
||||
digest += base;
|
||||
}
|
||||
return digest;
|
||||
@ -31,8 +31,7 @@ circuit PedersenHash {
|
||||
function main(hash_input: [bool; 512]) -> bool {
|
||||
const parameters = [0u32; 512];
|
||||
const pedersen = PedersenHash::new(parameters);
|
||||
const res = pedersen.hash(hash_input);
|
||||
let res = pedersen.hash(hash_input);
|
||||
|
||||
console.assert(res == 0u32);
|
||||
return res == 0u32;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ inputs:
|
||||
*/
|
||||
|
||||
function main(s: bool, a: i8, b: i8, c: i8) {
|
||||
const r = s ? a : b;
|
||||
let r = s ? a : b;
|
||||
|
||||
console.assert(r == c);
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,6 @@ input_file: input/dummy.in
|
||||
function main() -> bool {
|
||||
let x = 2u8;
|
||||
let y = x;
|
||||
const z = y / 2u8;
|
||||
let z = y / 2u8;
|
||||
return z == 1;
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ input_file: input/dummy.in
|
||||
|
||||
// Swap two elements of an array.
|
||||
function swap(a: [u32; 2], const i: u32, const j: u32) -> [u32; 2] {
|
||||
const t = a[i];
|
||||
let t = a[i];
|
||||
a[i] = a[j];
|
||||
a[j] = t;
|
||||
return a;
|
||||
@ -14,7 +14,7 @@ function swap(a: [u32; 2], const i: u32, const j: u32) -> [u32; 2] {
|
||||
|
||||
function main(arr: [u32; 2]) -> bool {
|
||||
const expected: [u32; 2] = [1, 0];
|
||||
const actual = swap(arr, 0, 1);
|
||||
let actual = swap(arr, 0, 1);
|
||||
|
||||
// Do swap.
|
||||
return expected[0] == actual[0] && expected[1] == actual[1];
|
||||
|
@ -13,7 +13,7 @@ function main(x: u32) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
const r: u32 = x == 3 ? 6 : 0;
|
||||
let r: u32 = x == 3 ? 6 : 0;
|
||||
|
||||
return r == b;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ input_file: inputs/true_true.in
|
||||
*/
|
||||
|
||||
function main(a: (bool, bool)) -> (bool, bool) {
|
||||
const a = (a.0 ? false : true, a.1 ? false : true);
|
||||
let a = (a.0 ? false : true, a.1 ? false : true);
|
||||
|
||||
return (a.0, a.1);
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ input_file: inputs/true_true.in
|
||||
*/
|
||||
|
||||
function main(a: (bool, bool)) -> (bool, bool) {
|
||||
const (a, b) = (a.0 ? false : true, a.1 ? false : true);
|
||||
let (a, b) = (a.0 ? false : true, a.1 ? false : true);
|
||||
|
||||
return (b, a);
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ input_file: inputs/true_true.in
|
||||
*/
|
||||
|
||||
function main(a: (bool, bool)) -> (bool, bool) {
|
||||
const b = (a, false);
|
||||
let b = (a, false);
|
||||
|
||||
return (b.1 || b.0.0, b.1 && b.0.1);
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ expectation: Pass
|
||||
outputs:
|
||||
- circuit:
|
||||
num_public_variables: 0
|
||||
num_private_variables: 23
|
||||
num_constraints: 23
|
||||
at: 1b2521e1b6fa3c84507b93ff0c68d463de22e8fcf6e750ff11dbf856494e9851
|
||||
bt: e07261c391194324de6c9bb8706ff09c30ce64dfc55ce30bd8aa4b19f7b1443a
|
||||
ct: f053ce5b6adb30f5c4f21f4c4c4001a77517d9c0ca3d113cece2585b22e56635
|
||||
num_private_variables: 1
|
||||
num_constraints: 1
|
||||
at: 042610d0fd1fe6d6ac112138f8755752f44c7d2a00f1b5960574d6da5cda393f
|
||||
bt: e97756698880ab7555a959a5fb5c6b4e15bd64612aa677adbfe2d0bd91f0a83c
|
||||
ct: cf1cbb66a638b4860a516671fb74850e6ccf787fe6c4c8d29e9c04efe880bd05
|
||||
output:
|
||||
- input_file: inline.in
|
||||
output:
|
||||
|
@ -4,11 +4,11 @@ expectation: Pass
|
||||
outputs:
|
||||
- circuit:
|
||||
num_public_variables: 0
|
||||
num_private_variables: 33854
|
||||
num_constraints: 50750
|
||||
at: ef530d618c6915bbff2137e7f057b1135dacbdd02e8d4be420320999724633ad
|
||||
bt: 4ec9fd3915bf2762cb32a7f7805918c1b976ca6c59852f505089fd23c0f321b7
|
||||
ct: e13fb652749582faae780837f6de4900f3b6c7202289d2219a543bfdd4f6836e
|
||||
num_private_variables: 33823
|
||||
num_constraints: 50719
|
||||
at: 894e21b7ca1c178a167a94f174b4ea0d37b102b394100a15c92e78e16a87acdf
|
||||
bt: 6756180897cb6c9fe53fce913fd9ad1c77a5b537b805da2c7f42de0473d12c94
|
||||
ct: 2f2e90dcee9f8a28e7a9fd4ee37093e4d247d07e4ab97937ecd0ba60ec5dd903
|
||||
output:
|
||||
- input_file: pedersen.in
|
||||
output:
|
||||
|
Loading…
Reference in New Issue
Block a user