2020-07-31 02:37:01 +03:00
|
|
|
use crate::{assert_satisfied, expect_compiler_error, generate_main_inputs, parse_program};
|
|
|
|
use leo_types::InputValue;
|
2020-05-19 22:41:21 +03:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_let() {
|
2020-06-09 04:55:44 +03:00
|
|
|
let bytes = include_bytes!("let.leo");
|
|
|
|
let program = parse_program(bytes).unwrap();
|
|
|
|
|
2020-07-31 02:37:01 +03:00
|
|
|
expect_compiler_error(program);
|
2020-05-19 22:41:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_let_mut() {
|
2020-06-09 04:55:44 +03:00
|
|
|
let bytes = include_bytes!("let_mut.leo");
|
|
|
|
let program = parse_program(bytes).unwrap();
|
|
|
|
|
2020-07-31 02:37:01 +03:00
|
|
|
assert_satisfied(program);
|
2020-05-19 22:41:21 +03:00
|
|
|
}
|
|
|
|
|
2020-06-30 06:29:53 +03:00
|
|
|
#[test]
|
|
|
|
fn test_const_fail() {
|
|
|
|
let bytes = include_bytes!("const.leo");
|
|
|
|
let program = parse_program(bytes).unwrap();
|
|
|
|
|
2020-07-31 02:37:01 +03:00
|
|
|
expect_compiler_error(program);
|
2020-06-30 06:29:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_const_mut_fail() {
|
|
|
|
let bytes = include_bytes!("const_mut.leo");
|
|
|
|
let program = parse_program(bytes).unwrap();
|
|
|
|
|
2020-07-31 02:37:01 +03:00
|
|
|
expect_compiler_error(program);
|
2020-06-30 06:29:53 +03:00
|
|
|
}
|
|
|
|
|
2020-05-19 22:41:21 +03:00
|
|
|
#[test]
|
|
|
|
fn test_array() {
|
2020-06-09 04:55:44 +03:00
|
|
|
let bytes = include_bytes!("array.leo");
|
|
|
|
let program = parse_program(bytes).unwrap();
|
|
|
|
|
2020-07-31 02:37:01 +03:00
|
|
|
expect_compiler_error(program);
|
2020-05-19 22:41:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_array_mut() {
|
2020-06-09 04:55:44 +03:00
|
|
|
let bytes = include_bytes!("array_mut.leo");
|
|
|
|
let program = parse_program(bytes).unwrap();
|
|
|
|
|
2020-07-31 02:37:01 +03:00
|
|
|
assert_satisfied(program);
|
2020-05-19 22:41:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_circuit() {
|
2020-06-09 04:55:44 +03:00
|
|
|
let bytes = include_bytes!("circuit.leo");
|
|
|
|
let program = parse_program(bytes).unwrap();
|
|
|
|
|
2020-07-31 02:37:01 +03:00
|
|
|
expect_compiler_error(program);
|
2020-05-19 22:41:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_circuit_mut() {
|
2020-06-09 04:55:44 +03:00
|
|
|
let bytes = include_bytes!("circuit_mut.leo");
|
|
|
|
let program = parse_program(bytes).unwrap();
|
|
|
|
|
2020-07-31 02:37:01 +03:00
|
|
|
assert_satisfied(program);
|
2020-05-19 22:41:21 +03:00
|
|
|
}
|
|
|
|
|
2020-05-19 22:01:19 +03:00
|
|
|
#[test]
|
|
|
|
fn test_function_input() {
|
2020-06-09 04:55:44 +03:00
|
|
|
let bytes = include_bytes!("function_input.leo");
|
|
|
|
let mut program = parse_program(bytes).unwrap();
|
|
|
|
|
2020-07-31 02:37:01 +03:00
|
|
|
let main_inputs = generate_main_inputs(vec![("a", Some(InputValue::Boolean(true)))]);
|
|
|
|
|
|
|
|
program.set_main_inputs(main_inputs);
|
|
|
|
|
|
|
|
expect_compiler_error(program);
|
2020-05-19 22:01:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_function_input_mut() {
|
2020-06-09 04:55:44 +03:00
|
|
|
let bytes = include_bytes!("function_input_mut.leo");
|
|
|
|
let mut program = parse_program(bytes).unwrap();
|
|
|
|
|
2020-07-31 02:37:01 +03:00
|
|
|
let main_inputs = generate_main_inputs(vec![("a", Some(InputValue::Boolean(true)))]);
|
|
|
|
|
|
|
|
program.set_main_inputs(main_inputs);
|
|
|
|
|
|
|
|
assert_satisfied(program);
|
2020-05-19 22:01:19 +03:00
|
|
|
}
|