-
Notifications
You must be signed in to change notification settings - Fork 658
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #536 from AleoHQ/fix/return-type-check
Fix/return type check
- Loading branch information
Showing
11 changed files
with
102 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,5 @@ | |
|
||
mod program_input; | ||
mod program_input_and_program_state; | ||
mod program_registers; | ||
mod program_state; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[registers] | ||
r2: [[u8; 4]; 2] = [[0u64, 0u64, 0u64, 0u64], [0u64, 0u64, 0u64, 0u64]]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[main] | ||
|
||
[registers] | ||
r: u8 = 0u8; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright (C) 2019-2020 Aleo Systems Inc. | ||
// This file is part of the Leo library. | ||
|
||
// The Leo library is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// The Leo library is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
use crate::{expect_compiler_error, get_output, parse_program_with_input}; | ||
|
||
#[test] | ||
fn test_registers_pass() { | ||
let program_string = include_str!("registers_pass.leo"); | ||
let input_string = include_str!("input/main.in"); | ||
let expected = include_bytes!("output/registers_pass.out"); | ||
|
||
let program = parse_program_with_input(program_string, input_string).unwrap(); | ||
|
||
let actual = get_output(program); | ||
|
||
assert!(expected.eq(actual.bytes().as_slice())); | ||
} | ||
|
||
#[test] | ||
fn test_registers_fail() { | ||
let program_string = include_str!("registers_fail.leo"); | ||
let input_string = include_str!("input/main.in"); | ||
|
||
let program = parse_program_with_input(program_string, input_string).unwrap(); | ||
|
||
expect_compiler_error(program); | ||
} | ||
|
||
#[test] | ||
fn test_registers_array() { | ||
let program_string = include_str!("registers_array.leo"); | ||
let input_string = include_str!("input/array.in"); | ||
let expected = include_bytes!("output/registers_array.out"); | ||
|
||
let program = parse_program_with_input(program_string, input_string).unwrap(); | ||
|
||
let actual = get_output(program); | ||
|
||
assert!(expected.eq(actual.bytes().as_slice())); | ||
} |
2 changes: 2 additions & 0 deletions
2
compiler/tests/input_files/program_registers/output/registers_array.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[registers] | ||
r2: [[u8; 4]; 2] = [[1, 2, 3, 4], [5, 6, 7, 8]]; |
2 changes: 2 additions & 0 deletions
2
compiler/tests/input_files/program_registers/output/registers_pass.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[registers] | ||
r: u8 = 1; |
3 changes: 3 additions & 0 deletions
3
compiler/tests/input_files/program_registers/registers_array.leo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function main () -> [[u8; 4]; 2] { | ||
return [[1u8, 2u8, 3u8, 4u8], [5u8, 6u8, 7u8, 8u8]] | ||
} |
3 changes: 3 additions & 0 deletions
3
compiler/tests/input_files/program_registers/registers_fail.leo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function main() -> bool { | ||
return false | ||
} |
3 changes: 3 additions & 0 deletions
3
compiler/tests/input_files/program_registers/registers_pass.leo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function main() -> u8 { | ||
return 1u8 | ||
} |