mirror of
https://github.com/AleoHQ/leo.git
synced 2024-11-13 08:47:17 +03:00
Passing parser test
This commit is contained in:
parent
dd48b6e29c
commit
1dde26baec
210
tests/expectations/parser/program/external_mapping.out
Normal file
210
tests/expectations/parser/program/external_mapping.out
Normal file
@ -0,0 +1,210 @@
|
||||
---
|
||||
namespace: Parse
|
||||
expectation: Pass
|
||||
outputs:
|
||||
- imports:
|
||||
hello:
|
||||
- imports: {}
|
||||
stubs: {}
|
||||
program_scopes: {}
|
||||
- lo: 1
|
||||
hi: 19
|
||||
stubs: {}
|
||||
program_scopes:
|
||||
test:
|
||||
program_id: "{\"name\":\"test\",\"network\":\"\\\"{\\\\\\\"id\\\\\\\":\\\\\\\"2\\\\\\\",\\\\\\\"name\\\\\\\":\\\\\\\"aleo\\\\\\\",\\\\\\\"span\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"lo\\\\\\\\\\\\\\\":0,\\\\\\\\\\\\\\\"hi\\\\\\\\\\\\\\\":0}\\\\\\\"}\\\"\"}"
|
||||
consts: []
|
||||
structs: []
|
||||
mappings: []
|
||||
functions:
|
||||
- - main
|
||||
- annotations: []
|
||||
variant: Standard
|
||||
identifier: "{\"id\":\"3\",\"name\":\"main\",\"span\":\"{\\\"lo\\\":53,\\\"hi\\\":57}\"}"
|
||||
input: []
|
||||
output: []
|
||||
output_type: Unit
|
||||
block:
|
||||
statements:
|
||||
- Definition:
|
||||
declaration_type: Let
|
||||
place:
|
||||
Identifier: "{\"id\":\"4\",\"name\":\"x\",\"span\":\"{\\\"lo\\\":74,\\\"hi\\\":75}\"}"
|
||||
type_:
|
||||
Integer: U8
|
||||
value:
|
||||
Literal:
|
||||
Integer:
|
||||
- U8
|
||||
- "1"
|
||||
- span:
|
||||
lo: 81
|
||||
hi: 84
|
||||
- 5
|
||||
span:
|
||||
lo: 70
|
||||
hi: 84
|
||||
id: 6
|
||||
- Return:
|
||||
expression:
|
||||
Unit:
|
||||
span:
|
||||
lo: 101
|
||||
hi: 105
|
||||
id: 7
|
||||
finalize_arguments: []
|
||||
span:
|
||||
lo: 94
|
||||
hi: 117
|
||||
id: 8
|
||||
span:
|
||||
lo: 60
|
||||
hi: 123
|
||||
id: 9
|
||||
finalize:
|
||||
identifier: "{\"id\":\"10\",\"name\":\"main\",\"span\":\"{\\\"lo\\\":137,\\\"hi\\\":141}\"}"
|
||||
input: []
|
||||
output: []
|
||||
output_type: Unit
|
||||
block:
|
||||
statements:
|
||||
- Expression:
|
||||
expression:
|
||||
Access:
|
||||
AssociatedFunction:
|
||||
variant: "{\"id\":\"11\",\"name\":\"Mapping\",\"span\":\"{\\\"lo\\\":154,\\\"hi\\\":161}\"}"
|
||||
name: "{\"id\":\"12\",\"name\":\"set\",\"span\":\"{\\\"lo\\\":163,\\\"hi\\\":166}\"}"
|
||||
arguments:
|
||||
- Locator: "{\"id\":\"15\",\"name\":\"counter\",\"program\":\"hello\",\"span\":\"{\\\"lo\\\":167,\\\"hi\\\":185}\"}"
|
||||
- Identifier: "{\"id\":\"16\",\"name\":\"addr\",\"span\":\"{\\\"lo\\\":187,\\\"hi\\\":191}\"}"
|
||||
- Binary:
|
||||
left:
|
||||
Identifier: "{\"id\":\"17\",\"name\":\"current_value\",\"span\":\"{\\\"lo\\\":193,\\\"hi\\\":206}\"}"
|
||||
right:
|
||||
Literal:
|
||||
Integer:
|
||||
- U64
|
||||
- "1"
|
||||
- span:
|
||||
lo: 209
|
||||
hi: 213
|
||||
- 18
|
||||
op: Add
|
||||
span:
|
||||
lo: 193
|
||||
hi: 213
|
||||
id: 19
|
||||
span:
|
||||
lo: 154
|
||||
hi: 214
|
||||
id: 20
|
||||
span:
|
||||
lo: 154
|
||||
hi: 215
|
||||
id: 21
|
||||
- Expression:
|
||||
expression:
|
||||
Access:
|
||||
AssociatedFunction:
|
||||
variant: "{\"id\":\"22\",\"name\":\"Mapping\",\"span\":\"{\\\"lo\\\":224,\\\"hi\\\":231}\"}"
|
||||
name: "{\"id\":\"23\",\"name\":\"remove\",\"span\":\"{\\\"lo\\\":233,\\\"hi\\\":239}\"}"
|
||||
arguments:
|
||||
- Locator: "{\"id\":\"26\",\"name\":\"foo\",\"program\":\"hello\",\"span\":\"{\\\"lo\\\":240,\\\"hi\\\":254}\"}"
|
||||
- Identifier: "{\"id\":\"27\",\"name\":\"addr\",\"span\":\"{\\\"lo\\\":256,\\\"hi\\\":260}\"}"
|
||||
span:
|
||||
lo: 224
|
||||
hi: 261
|
||||
id: 28
|
||||
span:
|
||||
lo: 224
|
||||
hi: 262
|
||||
id: 29
|
||||
- Definition:
|
||||
declaration_type: Let
|
||||
place:
|
||||
Identifier: "{\"id\":\"30\",\"name\":\"a\",\"span\":\"{\\\"lo\\\":275,\\\"hi\\\":276}\"}"
|
||||
type_:
|
||||
Integer: U32
|
||||
value:
|
||||
Access:
|
||||
AssociatedFunction:
|
||||
variant: "{\"id\":\"31\",\"name\":\"Mapping\",\"span\":\"{\\\"lo\\\":283,\\\"hi\\\":290}\"}"
|
||||
name: "{\"id\":\"32\",\"name\":\"get\",\"span\":\"{\\\"lo\\\":292,\\\"hi\\\":295}\"}"
|
||||
arguments:
|
||||
- Locator: "{\"id\":\"35\",\"name\":\"foo\",\"program\":\"hello\",\"span\":\"{\\\"lo\\\":296,\\\"hi\\\":310}\"}"
|
||||
- Identifier: "{\"id\":\"36\",\"name\":\"addr\",\"span\":\"{\\\"lo\\\":312,\\\"hi\\\":316}\"}"
|
||||
span:
|
||||
lo: 283
|
||||
hi: 317
|
||||
id: 37
|
||||
span:
|
||||
lo: 271
|
||||
hi: 317
|
||||
id: 38
|
||||
- Definition:
|
||||
declaration_type: Let
|
||||
place:
|
||||
Identifier: "{\"id\":\"39\",\"name\":\"b\",\"span\":\"{\\\"lo\\\":331,\\\"hi\\\":332}\"}"
|
||||
type_:
|
||||
Integer: U32
|
||||
value:
|
||||
Access:
|
||||
AssociatedFunction:
|
||||
variant: "{\"id\":\"40\",\"name\":\"Mapping\",\"span\":\"{\\\"lo\\\":339,\\\"hi\\\":346}\"}"
|
||||
name: "{\"id\":\"41\",\"name\":\"get_or_use\",\"span\":\"{\\\"lo\\\":348,\\\"hi\\\":358}\"}"
|
||||
arguments:
|
||||
- Locator: "{\"id\":\"44\",\"name\":\"foo\",\"program\":\"hello\",\"span\":\"{\\\"lo\\\":359,\\\"hi\\\":373}\"}"
|
||||
- Identifier: "{\"id\":\"45\",\"name\":\"addr\",\"span\":\"{\\\"lo\\\":375,\\\"hi\\\":379}\"}"
|
||||
- Literal:
|
||||
Integer:
|
||||
- U64
|
||||
- "0"
|
||||
- span:
|
||||
lo: 381
|
||||
hi: 385
|
||||
- 46
|
||||
span:
|
||||
lo: 339
|
||||
hi: 386
|
||||
id: 47
|
||||
span:
|
||||
lo: 327
|
||||
hi: 386
|
||||
id: 48
|
||||
- Definition:
|
||||
declaration_type: Let
|
||||
place:
|
||||
Identifier: "{\"id\":\"49\",\"name\":\"c\",\"span\":\"{\\\"lo\\\":400,\\\"hi\\\":401}\"}"
|
||||
type_:
|
||||
Integer: U32
|
||||
value:
|
||||
Access:
|
||||
AssociatedFunction:
|
||||
variant: "{\"id\":\"50\",\"name\":\"Mapping\",\"span\":\"{\\\"lo\\\":408,\\\"hi\\\":415}\"}"
|
||||
name: "{\"id\":\"51\",\"name\":\"contains\",\"span\":\"{\\\"lo\\\":417,\\\"hi\\\":425}\"}"
|
||||
arguments:
|
||||
- Locator: "{\"id\":\"54\",\"name\":\"foo\",\"program\":\"hello\",\"span\":\"{\\\"lo\\\":426,\\\"hi\\\":440}\"}"
|
||||
- Identifier: "{\"id\":\"55\",\"name\":\"addr\",\"span\":\"{\\\"lo\\\":442,\\\"hi\\\":446}\"}"
|
||||
span:
|
||||
lo: 408
|
||||
hi: 447
|
||||
id: 56
|
||||
span:
|
||||
lo: 396
|
||||
hi: 447
|
||||
id: 57
|
||||
span:
|
||||
lo: 144
|
||||
hi: 454
|
||||
id: 58
|
||||
span:
|
||||
lo: 128
|
||||
hi: 454
|
||||
id: 59
|
||||
span:
|
||||
lo: 44
|
||||
hi: 123
|
||||
id: 60
|
||||
span:
|
||||
lo: 20
|
||||
hi: 456
|
18
tests/tests/parser/program/external_mapping.leo
Normal file
18
tests/tests/parser/program/external_mapping.leo
Normal file
@ -0,0 +1,18 @@
|
||||
/*
|
||||
namespace: Parse
|
||||
expectation: Pass
|
||||
*/
|
||||
import hello.aleo;
|
||||
program test.aleo {
|
||||
function main() {
|
||||
let x:u8 = 1u8;
|
||||
return then finalize();
|
||||
}
|
||||
finalize main() {
|
||||
Mapping::set(hello.aleo/counter, addr, current_value + 1u64);
|
||||
Mapping::remove(hello.aleo/foo, addr);
|
||||
let a:u32 = Mapping::get(hello.aleo/foo, addr);
|
||||
let b:u32 = Mapping::get_or_use(hello.aleo/foo, addr, 0u64);
|
||||
let c:u32 = Mapping::contains(hello.aleo/foo, addr);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user