leo/asg/tests/pass/circuits/mod.rs

124 lines
3.0 KiB
Rust
Raw Normal View History

2021-02-02 07:26:56 +03:00
// Copyright (C) 2019-2021 Aleo Systems Inc.
2021-01-25 18:17:42 +03:00
// This file is part of the Leo library.
// The Leo library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// The Leo library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::load_asg;
// Expressions
#[test]
fn test_inline() {
let program_string = include_str!("inline.leo");
2021-02-25 18:40:47 +03:00
load_asg(program_string).unwrap();
2021-01-25 18:17:42 +03:00
}
// Members
#[test]
fn test_member_variable() {
let program_string = include_str!("member_variable.leo");
2021-02-25 18:40:47 +03:00
load_asg(program_string).unwrap();
2021-01-25 18:17:42 +03:00
}
#[test]
fn test_member_variable_and_function() {
let program_string = include_str!("member_variable_and_function.leo");
2021-02-25 18:40:47 +03:00
load_asg(program_string).unwrap();
2021-01-25 18:17:42 +03:00
}
#[test]
fn test_member_function() {
let program_string = include_str!("member_function.leo");
2021-02-25 18:40:47 +03:00
load_asg(program_string).unwrap();
2021-01-25 18:17:42 +03:00
}
#[test]
fn test_mut_member_function() {
let program_string = r#"
circuit Foo {
function echo(mut self, x: u32) -> u32 {
return x;
2021-01-25 18:17:42 +03:00
}
}
function main() {
let a = Foo { };
2021-01-25 18:17:42 +03:00
console.assert(a.echo(1u32) == 1u32);
}"#;
2021-02-25 18:40:47 +03:00
load_asg(program_string).unwrap();
2021-01-25 18:17:42 +03:00
}
#[test]
fn test_member_function_nested() {
let program_string = include_str!("member_function_nested.leo");
2021-02-25 18:40:47 +03:00
load_asg(program_string).unwrap();
2021-01-25 18:17:42 +03:00
}
#[test]
fn test_member_static_function() {
let program_string = include_str!("member_static_function.leo");
2021-02-25 18:40:47 +03:00
load_asg(program_string).unwrap();
2021-01-25 18:17:42 +03:00
}
// Mutability
#[test]
fn test_mutate_self_variable() {
let program_string = include_str!("mut_self_variable.leo");
2021-02-25 18:40:47 +03:00
load_asg(program_string).unwrap();
2021-01-25 18:17:42 +03:00
}
#[test]
fn test_mutate_self_variable_conditional() {
let program_string = include_str!("mut_self_variable_conditional.leo");
2021-02-25 18:40:47 +03:00
load_asg(program_string).unwrap();
2021-01-25 18:17:42 +03:00
}
#[test]
fn test_mutate_variable() {
let program_string = include_str!("mut_variable.leo");
2021-02-25 18:40:47 +03:00
load_asg(program_string).unwrap();
2021-01-25 18:17:42 +03:00
}
// Self
#[test]
fn test_self_member_pass() {
let program_string = include_str!("self_member.leo");
2021-02-25 18:40:47 +03:00
load_asg(program_string).unwrap();
2021-01-25 18:17:42 +03:00
}
// All
#[test]
fn test_define_circuit_inside_circuit_function() {
let program_string = include_str!("define_circuit_inside_circuit_function.leo");
2021-02-25 18:40:47 +03:00
load_asg(program_string).unwrap();
2021-01-25 18:17:42 +03:00
}
2021-02-11 22:59:14 +03:00
#[test]
fn test_circuit_explicit_define() {
let program_string = r#"
circuit One {
x: u8,
}
function main () {
let x: One = One {x: 5};
}
"#;
2021-02-25 18:40:47 +03:00
load_asg(program_string).unwrap();
2021-02-11 22:59:14 +03:00
}