mirror of
https://github.com/AleoHQ/leo.git
synced 2024-12-21 16:41:42 +03:00
Merge pull request #1352 from AleoHQ/more-tests
[Tests] Adds .len() parser tests, sanitizes some tests
This commit is contained in:
commit
bdfc79e90a
@ -1,5 +0,0 @@
|
||||
---
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [EASG0373043]: failed to resolve import: 'core.unstable.blake2s'\n --> compiler-test:3:30\n |\n 3 | import core.unstable.blake2s.BadCircuit; // `BadCircuit` is not included in the blake2s package\n | ^^^^^^^^^^"
|
@ -1,5 +0,0 @@
|
||||
---
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [EAST0372011]: failed to resolve import: 'core'\n --> compiler-test:3:13\n |\n 3 | import core.*; // You cannot import all dependencies from core at once\n | ^"
|
@ -1,5 +0,0 @@
|
||||
---
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [EAST0372011]: failed to resolve import: 'core'\n --> compiler-test:3:13\n |\n 3 | import core.bad_circuit; // `bad_circuit` is not a core package\n | ^^^^^^^^^^^"
|
@ -1,5 +0,0 @@
|
||||
---
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [EAST0372011]: failed to resolve import: 'core.unstable'\n --> compiler-test:3:22\n |\n 3 | import core.unstable.bad_circuit; // `bad_circuit` is not a core unstable package\n | ^^^^^^^^^^^"
|
204
tests/expectations/parser/parser/expression/array_len.leo.out
Normal file
204
tests/expectations/parser/parser/expression/array_len.leo.out
Normal file
@ -0,0 +1,204 @@
|
||||
---
|
||||
namespace: ParseExpression
|
||||
expectation: Pass
|
||||
outputs:
|
||||
- LengthOf:
|
||||
inner:
|
||||
ArrayInit:
|
||||
element:
|
||||
Value:
|
||||
Integer:
|
||||
- U8
|
||||
- "0"
|
||||
- line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 2
|
||||
col_stop: 5
|
||||
path: ""
|
||||
content: "[0u8; 1].len()"
|
||||
dimensions:
|
||||
- value: "1"
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 9
|
||||
path: ""
|
||||
content: "[0u8; 1].len()"
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 9
|
||||
path: ""
|
||||
content: "[0u8; 1].len()"
|
||||
- LengthOf:
|
||||
inner:
|
||||
ArrayInit:
|
||||
element:
|
||||
Value:
|
||||
Implicit:
|
||||
- "0"
|
||||
- line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 2
|
||||
col_stop: 3
|
||||
path: ""
|
||||
content: "[0; 1].len()"
|
||||
dimensions:
|
||||
- value: "1"
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 7
|
||||
path: ""
|
||||
content: "[0; 1].len()"
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 7
|
||||
path: ""
|
||||
content: "[0; 1].len()"
|
||||
- LengthOf:
|
||||
inner:
|
||||
ArrayInit:
|
||||
element:
|
||||
Value:
|
||||
Implicit:
|
||||
- "0"
|
||||
- line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 2
|
||||
col_stop: 3
|
||||
path: ""
|
||||
content: "[0; (1)].len()"
|
||||
dimensions:
|
||||
- value: "1"
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 9
|
||||
path: ""
|
||||
content: "[0; (1)].len()"
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 9
|
||||
path: ""
|
||||
content: "[0; (1)].len()"
|
||||
- LengthOf:
|
||||
inner:
|
||||
ArrayInit:
|
||||
element:
|
||||
Value:
|
||||
Implicit:
|
||||
- "0"
|
||||
- line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 2
|
||||
col_stop: 3
|
||||
path: ""
|
||||
content: "[0; (1, 2)].len()"
|
||||
dimensions:
|
||||
- value: "1"
|
||||
- value: "2"
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 12
|
||||
path: ""
|
||||
content: "[0; (1, 2)].len()"
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 12
|
||||
path: ""
|
||||
content: "[0; (1, 2)].len()"
|
||||
- LengthOf:
|
||||
inner:
|
||||
ArrayInit:
|
||||
element:
|
||||
Value:
|
||||
Implicit:
|
||||
- "0"
|
||||
- line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 2
|
||||
col_stop: 3
|
||||
path: ""
|
||||
content: "[0; (1, 2, 3)].len()"
|
||||
dimensions:
|
||||
- value: "1"
|
||||
- value: "2"
|
||||
- value: "3"
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 15
|
||||
path: ""
|
||||
content: "[0; (1, 2, 3)].len()"
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 15
|
||||
path: ""
|
||||
content: "[0; (1, 2, 3)].len()"
|
||||
- LengthOf:
|
||||
inner:
|
||||
ArrayInit:
|
||||
element:
|
||||
ArrayInit:
|
||||
element:
|
||||
ArrayInit:
|
||||
element:
|
||||
Value:
|
||||
Implicit:
|
||||
- "0"
|
||||
- line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 4
|
||||
col_stop: 5
|
||||
path: ""
|
||||
content: "[[[0; 3]; 2]; 1].len()"
|
||||
dimensions:
|
||||
- value: "3"
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 3
|
||||
col_stop: 9
|
||||
path: ""
|
||||
content: "[[[0; 3]; 2]; 1].len()"
|
||||
dimensions:
|
||||
- value: "2"
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 2
|
||||
col_stop: 13
|
||||
path: ""
|
||||
content: "[[[0; 3]; 2]; 1].len()"
|
||||
dimensions:
|
||||
- value: "1"
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 17
|
||||
path: ""
|
||||
content: "[[[0; 3]; 2]; 1].len()"
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 17
|
||||
path: ""
|
||||
content: "[[[0; 3]; 2]; 1].len()"
|
@ -0,0 +1,66 @@
|
||||
---
|
||||
namespace: Parse
|
||||
expectation: Pass
|
||||
outputs:
|
||||
- name: ""
|
||||
expected_input: []
|
||||
import_statements: []
|
||||
imports: {}
|
||||
aliases: {}
|
||||
circuits: {}
|
||||
global_consts: {}
|
||||
functions:
|
||||
"{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(x: [u8; _]) {\\\"}\"}":
|
||||
annotations: []
|
||||
identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(x: [u8; _]) {\\\"}\"}"
|
||||
input:
|
||||
- Variable:
|
||||
identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":12,\\\"col_stop\\\":13,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(x: [u8; _]) {\\\"}\"}"
|
||||
const_: false
|
||||
mutable: true
|
||||
type_:
|
||||
Array:
|
||||
- IntegerType: U8
|
||||
- - value: "0"
|
||||
span:
|
||||
line_start: 3
|
||||
line_stop: 3
|
||||
col_start: 12
|
||||
col_stop: 13
|
||||
path: ""
|
||||
content: "function x(x: [u8; _]) {"
|
||||
output: ~
|
||||
block:
|
||||
statements:
|
||||
- Return:
|
||||
expression:
|
||||
TupleInit:
|
||||
elements: []
|
||||
span:
|
||||
line_start: 4
|
||||
line_stop: 4
|
||||
col_start: 12
|
||||
col_stop: 14
|
||||
path: ""
|
||||
content: " return ();"
|
||||
span:
|
||||
line_start: 4
|
||||
line_stop: 4
|
||||
col_start: 5
|
||||
col_stop: 14
|
||||
path: ""
|
||||
content: " return ();"
|
||||
span:
|
||||
line_start: 3
|
||||
line_stop: 5
|
||||
col_start: 24
|
||||
col_stop: 2
|
||||
path: ""
|
||||
content: "function x(x: [u8; _]) {\n ...\n}"
|
||||
span:
|
||||
line_start: 3
|
||||
line_stop: 5
|
||||
col_start: 1
|
||||
col_stop: 2
|
||||
path: ""
|
||||
content: "function x(x: [u8; _]) {\n ...\n}"
|
@ -1471,3 +1471,143 @@ outputs:
|
||||
col_stop: 14
|
||||
path: ""
|
||||
content: "let (x,) = ();"
|
||||
- Definition:
|
||||
declaration_type: Let
|
||||
variable_names:
|
||||
- mutable: true
|
||||
identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":5,\\\"col_stop\\\":6,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"let x: [char; _] = \\\\\\\"Hello, World!\\\\\\\";\\\"}\"}"
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 5
|
||||
col_stop: 6
|
||||
path: ""
|
||||
content: "let x: [char; _] = \"Hello, World!\";"
|
||||
type_:
|
||||
Array:
|
||||
- Char
|
||||
- - value: "0"
|
||||
value:
|
||||
Value:
|
||||
String:
|
||||
- - Scalar: 72
|
||||
- Scalar: 101
|
||||
- Scalar: 108
|
||||
- Scalar: 108
|
||||
- Scalar: 111
|
||||
- Scalar: 44
|
||||
- Scalar: 32
|
||||
- Scalar: 87
|
||||
- Scalar: 111
|
||||
- Scalar: 114
|
||||
- Scalar: 108
|
||||
- Scalar: 100
|
||||
- Scalar: 33
|
||||
- line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 20
|
||||
col_stop: 35
|
||||
path: ""
|
||||
content: "let x: [char; _] = \"Hello, World!\";"
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 35
|
||||
path: ""
|
||||
content: "let x: [char; _] = \"Hello, World!\";"
|
||||
- Definition:
|
||||
declaration_type: Let
|
||||
variable_names:
|
||||
- mutable: true
|
||||
identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":5,\\\"col_stop\\\":6,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"let x: [[u8; 2]; 2] = [[0,0], [0,0]];\\\"}\"}"
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 5
|
||||
col_stop: 6
|
||||
path: ""
|
||||
content: "let x: [[u8; 2]; 2] = [[0,0], [0,0]];"
|
||||
type_:
|
||||
Array:
|
||||
- Array:
|
||||
- IntegerType: U8
|
||||
- - value: "2"
|
||||
- - value: "2"
|
||||
value:
|
||||
ArrayInline:
|
||||
elements:
|
||||
- Expression:
|
||||
ArrayInline:
|
||||
elements:
|
||||
- Expression:
|
||||
Value:
|
||||
Implicit:
|
||||
- "0"
|
||||
- line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 25
|
||||
col_stop: 26
|
||||
path: ""
|
||||
content: "let x: [[u8; 2]; 2] = [[0,0], [0,0]];"
|
||||
- Expression:
|
||||
Value:
|
||||
Implicit:
|
||||
- "0"
|
||||
- line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 27
|
||||
col_stop: 28
|
||||
path: ""
|
||||
content: "let x: [[u8; 2]; 2] = [[0,0], [0,0]];"
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 24
|
||||
col_stop: 29
|
||||
path: ""
|
||||
content: "let x: [[u8; 2]; 2] = [[0,0], [0,0]];"
|
||||
- Expression:
|
||||
ArrayInline:
|
||||
elements:
|
||||
- Expression:
|
||||
Value:
|
||||
Implicit:
|
||||
- "0"
|
||||
- line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 32
|
||||
col_stop: 33
|
||||
path: ""
|
||||
content: "let x: [[u8; 2]; 2] = [[0,0], [0,0]];"
|
||||
- Expression:
|
||||
Value:
|
||||
Implicit:
|
||||
- "0"
|
||||
- line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 34
|
||||
col_stop: 35
|
||||
path: ""
|
||||
content: "let x: [[u8; 2]; 2] = [[0,0], [0,0]];"
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 31
|
||||
col_stop: 36
|
||||
path: ""
|
||||
content: "let x: [[u8; 2]; 2] = [[0,0], [0,0]];"
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 23
|
||||
col_stop: 37
|
||||
path: ""
|
||||
content: "let x: [[u8; 2]; 2] = [[0,0], [0,0]];"
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 37
|
||||
path: ""
|
||||
content: "let x: [[u8; 2]; 2] = [[0,0], [0,0]];"
|
||||
|
16
tests/parser/expression/array_len.leo
Normal file
16
tests/parser/expression/array_len.leo
Normal file
@ -0,0 +1,16 @@
|
||||
/*
|
||||
namespace: ParseExpression
|
||||
expectation: Pass
|
||||
*/
|
||||
|
||||
[0u8; 1].len()
|
||||
|
||||
[0; 1].len()
|
||||
|
||||
[0; (1)].len()
|
||||
|
||||
[0; (1, 2)].len()
|
||||
|
||||
[0; (1, 2, 3)].len()
|
||||
|
||||
[[[0; 3]; 2]; 1].len()
|
8
tests/parser/functions/param_array_unsized.leo
Normal file
8
tests/parser/functions/param_array_unsized.leo
Normal file
@ -0,0 +1,8 @@
|
||||
/*
|
||||
namespace: Parse
|
||||
expectation: Pass
|
||||
*/
|
||||
|
||||
function x(x: [u8; _]) {
|
||||
return ();
|
||||
}
|
@ -98,3 +98,8 @@ const (x, y): u32 = x();
|
||||
let (x,y,) = ();
|
||||
|
||||
let (x,) = ();
|
||||
|
||||
|
||||
let x: [char; _] = "Hello, World!";
|
||||
|
||||
let x: [[u8; 2]; 2] = [[0,0], [0,0]];
|
||||
|
Loading…
Reference in New Issue
Block a user