Merge pull request #1352 from AleoHQ/more-tests

[Tests] Adds .len() parser tests, sanitizes some tests
This commit is contained in:
Alessandro Coglio 2021-09-17 11:05:39 -07:00 committed by GitHub
commit bdfc79e90a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 439 additions and 20 deletions

View File

@ -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 | ^^^^^^^^^^"

View File

@ -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 | ^"

View File

@ -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 | ^^^^^^^^^^^"

View File

@ -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 | ^^^^^^^^^^^"

View 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()"

View File

@ -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}"

View File

@ -1471,3 +1471,143 @@ outputs:
col_stop: 14 col_stop: 14
path: "" path: ""
content: "let (x,) = ();" 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]];"

View 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()

View File

@ -0,0 +1,8 @@
/*
namespace: Parse
expectation: Pass
*/
function x(x: [u8; _]) {
return ();
}

View File

@ -98,3 +98,8 @@ const (x, y): u32 = x();
let (x,y,) = (); let (x,y,) = ();
let (x,) = (); let (x,) = ();
let x: [char; _] = "Hello, World!";
let x: [[u8; 2]; 2] = [[0,0], [0,0]];