mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-11-24 07:48:04 +03:00
test mutable circuit variables
This commit is contained in:
parent
87781fed03
commit
d35188abcb
9
compiler/tests/mutability/circuit_function_mut.leo
Normal file
9
compiler/tests/mutability/circuit_function_mut.leo
Normal file
@ -0,0 +1,9 @@
|
||||
// Adding the `mut` keyword makes a circuit variable mutable.
|
||||
circuit Foo {
|
||||
function bar() {}
|
||||
}
|
||||
|
||||
function main() {
|
||||
let mut a = Foo { x: 1 };
|
||||
a.bar = 0;
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
// Adding the `mut` keyword makes a circuit variable mutable.
|
||||
circuit Foo {
|
||||
static function bar() {}
|
||||
}
|
||||
|
||||
function main() {
|
||||
let mut a = Foo { x: 1 };
|
||||
a.bar = 0;
|
||||
}
|
11
compiler/tests/mutability/circuit_variable_mut.leo
Normal file
11
compiler/tests/mutability/circuit_variable_mut.leo
Normal file
@ -0,0 +1,11 @@
|
||||
// Adding the `mut` keyword makes a circuit variable mutable.
|
||||
circuit Foo {
|
||||
mut x: u32
|
||||
}
|
||||
|
||||
function main() {
|
||||
let mut a = Foo { x: 1 };
|
||||
a.x = 0;
|
||||
|
||||
console.assert(a.x == 0u32);
|
||||
}
|
@ -78,9 +78,33 @@ fn test_circuit_mut() {
|
||||
let bytes = include_bytes!("circuit_mut.leo");
|
||||
let program = parse_program(bytes).unwrap();
|
||||
|
||||
expect_compiler_error(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_circuit_variable_mut() {
|
||||
let bytes = include_bytes!("circuit_variable_mut.leo");
|
||||
let program = parse_program(bytes).unwrap();
|
||||
|
||||
assert_satisfied(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_circuit_function_mut() {
|
||||
let bytes = include_bytes!("circuit_function_mut.leo");
|
||||
let program = parse_program(bytes).unwrap();
|
||||
|
||||
expect_compiler_error(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_circuit_static_function_mut() {
|
||||
let bytes = include_bytes!("circuit_static_function_mut.leo");
|
||||
let program = parse_program(bytes).unwrap();
|
||||
|
||||
expect_compiler_error(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_function_input() {
|
||||
let bytes = include_bytes!("function_input.leo");
|
||||
|
Loading…
Reference in New Issue
Block a user