mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-11-24 07:48:04 +03:00
rename _test to test_
This commit is contained in:
parent
dbaa334eb6
commit
c3e2ba420f
@ -1,4 +1,3 @@
|
|||||||
function main(a: i8, b: i8) -> i8 {
|
function main(a: i8, b: i8) -> i8 {
|
||||||
print!("{} - {}", a, b);
|
|
||||||
return a - b
|
return a - b
|
||||||
}
|
}
|
@ -1,9 +1,9 @@
|
|||||||
macro_rules! test_uint {
|
macro_rules! test_uint {
|
||||||
($name: ident, $_type: ty, $integer_type: expr, $gadget: ty) => {
|
($name: ident, $type_: ty, $integer_type: expr, $gadget: ty) => {
|
||||||
pub struct $name {}
|
pub struct $name {}
|
||||||
|
|
||||||
impl $name {
|
impl $name {
|
||||||
fn test_min(min: $_type) {
|
fn test_min(min: $type_) {
|
||||||
let min_allocated = <$gadget>::constant(min);
|
let min_allocated = <$gadget>::constant(min);
|
||||||
|
|
||||||
let bytes = include_bytes!("min.leo");
|
let bytes = include_bytes!("min.leo");
|
||||||
@ -12,7 +12,7 @@ macro_rules! test_uint {
|
|||||||
output_expected_allocated(program, min_allocated);
|
output_expected_allocated(program, min_allocated);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_max(max: $_type) {
|
fn test_max(max: $type_) {
|
||||||
let max_allocated = <$gadget>::constant(max);
|
let max_allocated = <$gadget>::constant(max);
|
||||||
|
|
||||||
let bytes = include_bytes!("max.leo");
|
let bytes = include_bytes!("max.leo");
|
||||||
@ -25,7 +25,7 @@ macro_rules! test_uint {
|
|||||||
impl IntegerTester for $name {
|
impl IntegerTester for $name {
|
||||||
fn test_input() {
|
fn test_input() {
|
||||||
// valid input
|
// valid input
|
||||||
let num: $_type = rand::random();
|
let num: $type_ = rand::random();
|
||||||
let expected = <$gadget>::constant(num);
|
let expected = <$gadget>::constant(num);
|
||||||
|
|
||||||
let bytes = include_bytes!("input.leo");
|
let bytes = include_bytes!("input.leo");
|
||||||
@ -49,8 +49,8 @@ macro_rules! test_uint {
|
|||||||
|
|
||||||
fn test_add() {
|
fn test_add() {
|
||||||
for _ in 0..10 {
|
for _ in 0..10 {
|
||||||
let r1: $_type = rand::random();
|
let r1: $type_ = rand::random();
|
||||||
let r2: $_type = rand::random();
|
let r2: $type_ = rand::random();
|
||||||
|
|
||||||
let sum = r1.wrapping_add(r2);
|
let sum = r1.wrapping_add(r2);
|
||||||
|
|
||||||
@ -71,8 +71,8 @@ macro_rules! test_uint {
|
|||||||
|
|
||||||
fn test_sub() {
|
fn test_sub() {
|
||||||
for _ in 0..10 {
|
for _ in 0..10 {
|
||||||
let r1: $_type = rand::random();
|
let r1: $type_ = rand::random();
|
||||||
let r2: $_type = rand::random();
|
let r2: $type_ = rand::random();
|
||||||
|
|
||||||
let difference = match r1.checked_sub(r2) {
|
let difference = match r1.checked_sub(r2) {
|
||||||
Some(valid) => valid,
|
Some(valid) => valid,
|
||||||
@ -96,8 +96,8 @@ macro_rules! test_uint {
|
|||||||
|
|
||||||
fn test_mul() {
|
fn test_mul() {
|
||||||
for _ in 0..10 {
|
for _ in 0..10 {
|
||||||
let r1: $_type = rand::random();
|
let r1: $type_ = rand::random();
|
||||||
let r2: $_type = rand::random();
|
let r2: $type_ = rand::random();
|
||||||
|
|
||||||
let product = r1.wrapping_mul(r2);
|
let product = r1.wrapping_mul(r2);
|
||||||
|
|
||||||
@ -118,8 +118,8 @@ macro_rules! test_uint {
|
|||||||
|
|
||||||
fn test_div() {
|
fn test_div() {
|
||||||
// for _ in 0..10 {// these loops take an excessive amount of time
|
// for _ in 0..10 {// these loops take an excessive amount of time
|
||||||
let r1: $_type = rand::random();
|
let r1: $type_ = rand::random();
|
||||||
let r2: $_type = rand::random();
|
let r2: $type_ = rand::random();
|
||||||
|
|
||||||
let bytes = include_bytes!("div.leo");
|
let bytes = include_bytes!("div.leo");
|
||||||
let mut program = parse_program(bytes).unwrap();
|
let mut program = parse_program(bytes).unwrap();
|
||||||
@ -144,8 +144,8 @@ macro_rules! test_uint {
|
|||||||
|
|
||||||
fn test_pow() {
|
fn test_pow() {
|
||||||
// for _ in 0..10 {// these loops take an excessive amount of time
|
// for _ in 0..10 {// these loops take an excessive amount of time
|
||||||
let r1: $_type = rand::random();
|
let r1: $type_ = rand::random();
|
||||||
let r2: $_type = rand::random();
|
let r2: $type_ = rand::random();
|
||||||
let r2 = r2 as u32; // we cast to u32 here because of rust pow() requirements
|
let r2 = r2 as u32; // we cast to u32 here because of rust pow() requirements
|
||||||
|
|
||||||
let result = r1.wrapping_pow(r2);
|
let result = r1.wrapping_pow(r2);
|
||||||
@ -167,7 +167,7 @@ macro_rules! test_uint {
|
|||||||
|
|
||||||
fn test_eq() {
|
fn test_eq() {
|
||||||
for _ in 0..10 {
|
for _ in 0..10 {
|
||||||
let r1: $_type = rand::random();
|
let r1: $type_ = rand::random();
|
||||||
|
|
||||||
// test equal
|
// test equal
|
||||||
let bytes = include_bytes!("eq.leo");
|
let bytes = include_bytes!("eq.leo");
|
||||||
@ -181,7 +181,7 @@ macro_rules! test_uint {
|
|||||||
output_true(program);
|
output_true(program);
|
||||||
|
|
||||||
// test not equal
|
// test not equal
|
||||||
let r2: $_type = rand::random();
|
let r2: $type_ = rand::random();
|
||||||
|
|
||||||
let result = r1.eq(&r2);
|
let result = r1.eq(&r2);
|
||||||
|
|
||||||
@ -198,7 +198,7 @@ macro_rules! test_uint {
|
|||||||
|
|
||||||
fn test_ge() {
|
fn test_ge() {
|
||||||
for _ in 0..10 {
|
for _ in 0..10 {
|
||||||
let r1: $_type = rand::random();
|
let r1: $type_ = rand::random();
|
||||||
|
|
||||||
// test equal
|
// test equal
|
||||||
let bytes = include_bytes!("ge.leo");
|
let bytes = include_bytes!("ge.leo");
|
||||||
@ -212,7 +212,7 @@ macro_rules! test_uint {
|
|||||||
output_true(program);
|
output_true(program);
|
||||||
|
|
||||||
// test not equal
|
// test not equal
|
||||||
let r2: $_type = rand::random();
|
let r2: $type_ = rand::random();
|
||||||
|
|
||||||
let result = r1.ge(&r2);
|
let result = r1.ge(&r2);
|
||||||
|
|
||||||
@ -229,7 +229,7 @@ macro_rules! test_uint {
|
|||||||
|
|
||||||
fn test_gt() {
|
fn test_gt() {
|
||||||
for _ in 0..10 {
|
for _ in 0..10 {
|
||||||
let r1: $_type = rand::random();
|
let r1: $type_ = rand::random();
|
||||||
|
|
||||||
// test equal
|
// test equal
|
||||||
let bytes = include_bytes!("gt.leo");
|
let bytes = include_bytes!("gt.leo");
|
||||||
@ -243,7 +243,7 @@ macro_rules! test_uint {
|
|||||||
output_false(program);
|
output_false(program);
|
||||||
|
|
||||||
// test not equal
|
// test not equal
|
||||||
let r2: $_type = rand::random();
|
let r2: $type_ = rand::random();
|
||||||
|
|
||||||
let result = r1.gt(&r2);
|
let result = r1.gt(&r2);
|
||||||
|
|
||||||
@ -260,7 +260,7 @@ macro_rules! test_uint {
|
|||||||
|
|
||||||
fn test_le() {
|
fn test_le() {
|
||||||
for _ in 0..10 {
|
for _ in 0..10 {
|
||||||
let r1: $_type = rand::random();
|
let r1: $type_ = rand::random();
|
||||||
|
|
||||||
// test equal
|
// test equal
|
||||||
let bytes = include_bytes!("le.leo");
|
let bytes = include_bytes!("le.leo");
|
||||||
@ -274,7 +274,7 @@ macro_rules! test_uint {
|
|||||||
output_true(program);
|
output_true(program);
|
||||||
|
|
||||||
// test not equal
|
// test not equal
|
||||||
let r2: $_type = rand::random();
|
let r2: $type_ = rand::random();
|
||||||
|
|
||||||
let result = r1.le(&r2);
|
let result = r1.le(&r2);
|
||||||
|
|
||||||
@ -291,7 +291,7 @@ macro_rules! test_uint {
|
|||||||
|
|
||||||
fn test_lt() {
|
fn test_lt() {
|
||||||
for _ in 0..10 {
|
for _ in 0..10 {
|
||||||
let r1: $_type = rand::random();
|
let r1: $type_ = rand::random();
|
||||||
|
|
||||||
// test equal
|
// test equal
|
||||||
let bytes = include_bytes!("lt.leo");
|
let bytes = include_bytes!("lt.leo");
|
||||||
@ -304,7 +304,7 @@ macro_rules! test_uint {
|
|||||||
output_false(program);
|
output_false(program);
|
||||||
|
|
||||||
// test not equal
|
// test not equal
|
||||||
let r2: $_type = rand::random();
|
let r2: $type_ = rand::random();
|
||||||
|
|
||||||
let result = r1.lt(&r2);
|
let result = r1.lt(&r2);
|
||||||
|
|
||||||
@ -321,7 +321,7 @@ macro_rules! test_uint {
|
|||||||
|
|
||||||
fn test_assert_eq() {
|
fn test_assert_eq() {
|
||||||
for _ in 0..10 {
|
for _ in 0..10 {
|
||||||
let r1: $_type = rand::random();
|
let r1: $type_ = rand::random();
|
||||||
|
|
||||||
// test equal
|
// test equal
|
||||||
let bytes = include_bytes!("assert_eq.leo");
|
let bytes = include_bytes!("assert_eq.leo");
|
||||||
@ -335,7 +335,7 @@ macro_rules! test_uint {
|
|||||||
let _ = get_output(program);
|
let _ = get_output(program);
|
||||||
|
|
||||||
// test not equal
|
// test not equal
|
||||||
let r2: $_type = rand::random();
|
let r2: $type_ = rand::random();
|
||||||
|
|
||||||
if r1 == r2 {
|
if r1 == r2 {
|
||||||
continue;
|
continue;
|
||||||
@ -355,8 +355,8 @@ macro_rules! test_uint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn test_ternary() {
|
fn test_ternary() {
|
||||||
let r1: $_type = rand::random();
|
let r1: $type_ = rand::random();
|
||||||
let r2: $_type = rand::random();
|
let r2: $type_ = rand::random();
|
||||||
|
|
||||||
let g1 = <$gadget>::constant(r1);
|
let g1 = <$gadget>::constant(r1);
|
||||||
let g2 = <$gadget>::constant(r2);
|
let g2 = <$gadget>::constant(r2);
|
||||||
|
Loading…
Reference in New Issue
Block a user