folder of compiler tests for constants definitions and usages

This commit is contained in:
evan-schott 2023-09-22 12:56:05 -07:00
parent 3d573f046e
commit 02422ca411
10 changed files with 181 additions and 0 deletions

View File

@ -0,0 +1,22 @@
/*
namespace: Compile
expectation: Pass
*/
program test.aleo {
mapping account: address => u64;
mapping values: u8 => u8;
const BIG_NUMBER: u8 = 1u8;
transition finalize_self_caller() -> () {
return then finalize(self.caller);
}
finalize finalize_self_caller(caller: address) -> () {
const TINY: u8 = 3u8;
let current_value: u8 = Mapping::get_or_use(values, 0u8, 0u8) + TINY + BIG_NUMBER;
Mapping::set(values, 0u8, current_value + 1u8);
let current_amount: u64 = Mapping::get_or_use(account, caller, 0u64);
Mapping::set(account, caller, current_amount + 1u64);
}
}

View File

@ -0,0 +1,27 @@
/*
namespace: Compile
expectation: Pass
*/
program test.aleo {
const START: u8 = 0u8;
const START_2: u8 = 1u8;
const STOP_2: u8 = 20u8;
transition foo(a: u8, b: u8, flag: bool) -> u8 {
const STOP: u8 = 10u8;
let c:u8 = 1u8;
for i: u8 in START..STOP {
c = c + i;
}
for i: u8 in 0u8..STOP {
c = c + i;
}
for i: u8 in START..10u8 {
c = c + i;
}
for i: u8 in START_2..STOP_2 {
c = c + i;
}
return c;
}
}

View File

@ -0,0 +1,16 @@
/*
namespace: Compile
expectation: Fail
*/
program test.aleo {
const START: u32 = 0u32;
transition foo(a: u8, b: u8, flag: bool) -> u8 {
const STOP: u8 = 10u8;
let c:u8 = 1u8;
for i: u8 in START..STOP {
c = c + i;
}
return c;
}
}

View File

@ -0,0 +1,16 @@
/*
namespace: Compile
expectation: Fail
*/
program test.aleo {
const START: u8 = 10u8;
transition foo(a: u8, b: u8, flag: bool) -> u8 {
const STOP: u8 = 0u8;
let c:u8 = 1u8;
for i: u8 in START..STOP {
c = c + i;
}
return c;
}
}

View File

@ -0,0 +1,19 @@
/*
namespace: Compile
expectation: Fail
*/
program test.aleo {
const HELLO: u8 = 0u8;
transition foo(a: u8, b: u8, flag: bool) -> u8 {
let start: (u8, u8) = (a, b);
for i: u8 in 0u8..16u8 {
start = (start.0 + start.1, start.1 + 1u8);
if flag {
start = (start.1, start.0 + start.0);
const HELLO:u8 = 1u8;
}
}
return start.0 + start.1;
}
}

View File

@ -0,0 +1,28 @@
/*
namespace: Compile
expectation: Pass
*/
program test.aleo {
const START: u32 = 0u32;
transition foo(a: u32, b: u32, flag: bool) -> u32 {
const STOP: u32 = 10u32;
let c:u32 = 1u32;
for i: u32 in START..STOP {
for j: u32 in START..STOP {
const BIG_NUMBER:u32 = 1u32;
if flag {
const SUPER_SMALL_NUMBER:u32 = 99u32;
c = c + a + b + BIG_NUMBER + SUPER_SMALL_NUMBER;
} else {
const SUPER_SMALL_NUMBER:u32 = 88u32;
c = c + a - b + BIG_NUMBER + SUPER_SMALL_NUMBER;
for k: u32 in START..STOP {
c = c + a - b;
}
}
}
}
return c;
}
}

View File

@ -0,0 +1,19 @@
/*
namespace: Compile
expectation: Fail
*/
program test.aleo {
const HELLO: u8 = 0u8;
transition foo(a: u8, b: u8, flag: bool) -> u8 {
let start: (u8, u8) = (a, b);
for i: u8 in 0u8..16u8 {
start = (start.0 + start.1, start.1 + 1u8);
if flag {
start = (start.1, start.0 + start.0);
HELLO = 1u8 + 1u8;
}
}
return start.0 + start.1;
}
}

View File

@ -0,0 +1,11 @@
/*
namespace: Compile
expectation: Pass
*/
program test.aleo {
const (HELLO,GOODBYE): (u8,u8) = (1u8, 1u8);
transition foo(a: u8, b: u8, flag: bool) -> u8 {
return GOODBYE;
}
}

View File

@ -0,0 +1,11 @@
/*
namespace: Compile
expectation: Fail
*/
program test.aleo {
const (GOODBYE,HELLO): (u8,u8) = (0u8,(1u8,1u8));
transition foo(a: u8, b: u8, flag: bool) -> u8 {
return GOODBYE;
}
}

View File

@ -0,0 +1,12 @@
/*
namespace: Compile
expectation: Fail
*/
program test.aleo {
const (HELLO,GOODBYE): (u8,u8) = (0u8,0u8);
const HELLO: u8 = 0u8;
transition foo(a: u8, b: u8, flag: bool) -> u8 {
return 1u8;
}
}