mirror of
https://github.com/AleoHQ/leo.git
synced 2024-11-28 11:16:49 +03:00
allow newlines and trailing commas in function declarations
This commit is contained in:
parent
1c8699696c
commit
3d794c6a20
@ -191,7 +191,7 @@ type_circuit = { identifier }
|
||||
// Declared in types/array_type.rs
|
||||
type_array = { type_data ~ ("[" ~ number_positive ~ "]")+ }
|
||||
|
||||
type_tuple = { "(" ~ type_ ~ ("," ~ type_)+ ~ ")" }
|
||||
type_tuple = { "(" ~ NEWLINE* ~ type_ ~ ("," ~ NEWLINE* ~ type_)+ ~ ","? ~ NEWLINE* ~ ")" }
|
||||
|
||||
/// Values
|
||||
|
||||
@ -381,7 +381,7 @@ input = {
|
||||
function_input
|
||||
| input_keyword
|
||||
}
|
||||
input_tuple = _{ "(" ~(input ~ ("," ~ NEWLINE* ~ input)*)? ~ ")"}
|
||||
input_tuple = _{ "(" ~ NEWLINE* ~ (input ~ ("," ~ NEWLINE* ~ input)* ~ ","?)? ~ NEWLINE* ~ ")"}
|
||||
|
||||
|
||||
/// Imports
|
||||
|
7
compiler/tests/function/input/newlines.in
Normal file
7
compiler/tests/function/input/newlines.in
Normal file
@ -0,0 +1,7 @@
|
||||
[main]
|
||||
a: u32 = 0;
|
||||
b: u32 = 0;
|
||||
|
||||
[registers]
|
||||
a: u32 = 0;
|
||||
b: u32 = 0;
|
@ -41,6 +41,20 @@ fn test_iteration_repeated() {
|
||||
assert_satisfied(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_newlines() {
|
||||
let input_bytes = include_bytes!("input/newlines.in");
|
||||
let program_bytes = include_bytes!("newlines.leo");
|
||||
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
|
||||
|
||||
let expected_bytes = include_bytes!("output_/newlines.out");
|
||||
let expected = std::str::from_utf8(expected_bytes).unwrap();
|
||||
let actual_bytes = get_output(program);
|
||||
let actual = std::str::from_utf8(actual_bytes.bytes().as_slice()).unwrap();
|
||||
|
||||
assert_eq!(expected, actual);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_multiple_returns() {
|
||||
let bytes = include_bytes!("multiple.leo");
|
||||
|
9
compiler/tests/function/newlines.leo
Normal file
9
compiler/tests/function/newlines.leo
Normal file
@ -0,0 +1,9 @@
|
||||
function main(
|
||||
a: u32,
|
||||
b: u32,
|
||||
) -> (
|
||||
u32,
|
||||
u32,
|
||||
) {
|
||||
return (a, b)
|
||||
}
|
3
compiler/tests/function/output_/newlines.out
Normal file
3
compiler/tests/function/output_/newlines.out
Normal file
@ -0,0 +1,3 @@
|
||||
[registers]
|
||||
a: u32 = 0u32;
|
||||
b: u32 = 0u32;
|
Loading…
Reference in New Issue
Block a user