test mutable circuit variables

This commit is contained in:
collin 2020-09-02 18:01:47 -07:00
parent 87781fed03
commit d35188abcb
4 changed files with 53 additions and 0 deletions

View 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;
}

View File

@ -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;
}

View 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);
}

View File

@ -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");