2021-02-02 07:26:56 +03:00
|
|
|
// Copyright (C) 2019-2021 Aleo Systems Inc.
|
2020-08-18 13:50:26 +03:00
|
|
|
// 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/>.
|
|
|
|
|
2020-12-17 00:02:31 +03:00
|
|
|
use crate::{expect_asg_error, parse_input, parse_program};
|
|
|
|
use leo_compiler::errors::CompilerError;
|
2020-10-31 03:17:17 +03:00
|
|
|
use leo_grammar::ParserError;
|
2020-08-01 04:49:01 +03:00
|
|
|
use leo_input::InputParserError;
|
2020-06-05 01:44:38 +03:00
|
|
|
|
2020-09-03 05:23:16 +03:00
|
|
|
pub mod identifiers;
|
|
|
|
|
2020-06-05 01:44:38 +03:00
|
|
|
#[test]
|
2020-08-11 00:46:36 +03:00
|
|
|
#[ignore]
|
2020-06-05 01:44:38 +03:00
|
|
|
fn test_semicolon() {
|
2020-12-04 23:48:43 +03:00
|
|
|
let program_string = include_str!("semicolon.leo");
|
|
|
|
let error = parse_program(program_string).err().unwrap();
|
2020-06-05 01:44:38 +03:00
|
|
|
|
|
|
|
match error {
|
2020-06-09 03:28:09 +03:00
|
|
|
CompilerError::ParserError(ParserError::SyntaxError(_)) => {}
|
2020-06-08 08:21:31 +03:00
|
|
|
_ => panic!("test_semicolon failed the wrong expected error, should be a ParserError"),
|
2020-06-05 01:44:38 +03:00
|
|
|
}
|
|
|
|
}
|
2020-06-11 21:43:05 +03:00
|
|
|
|
|
|
|
#[test]
|
2020-06-20 01:47:09 +03:00
|
|
|
fn test_undefined() {
|
2020-12-04 23:48:43 +03:00
|
|
|
let program_string = include_str!("undefined.leo");
|
2020-12-17 00:02:31 +03:00
|
|
|
let error = parse_program(program_string).err().unwrap();
|
2020-06-20 01:47:09 +03:00
|
|
|
|
2020-12-17 00:02:31 +03:00
|
|
|
expect_asg_error(error);
|
2020-06-11 21:43:05 +03:00
|
|
|
}
|
2020-06-20 01:47:09 +03:00
|
|
|
|
2020-06-20 09:02:58 +03:00
|
|
|
#[test]
|
2020-08-01 05:39:30 +03:00
|
|
|
fn input_syntax_error() {
|
2020-12-04 20:57:08 +03:00
|
|
|
let input_string = include_str!("input_semicolon.leo");
|
|
|
|
let error = parse_input(input_string).err().unwrap();
|
2020-06-20 09:02:58 +03:00
|
|
|
|
2020-10-24 03:00:11 +03:00
|
|
|
// Expect an input parser error.
|
2020-06-20 09:02:58 +03:00
|
|
|
match error {
|
|
|
|
CompilerError::InputParserError(InputParserError::SyntaxError(_)) => {}
|
2020-08-01 06:59:50 +03:00
|
|
|
_ => panic!("input syntax error should be a ParserError"),
|
2020-06-20 09:02:58 +03:00
|
|
|
}
|
|
|
|
}
|
2020-08-17 11:30:13 +03:00
|
|
|
|
2020-11-12 21:28:24 +03:00
|
|
|
#[test]
|
|
|
|
fn test_compare_mismatched_types() {
|
2020-12-04 23:48:43 +03:00
|
|
|
let program_string = include_str!("compare_mismatched_types.leo");
|
|
|
|
let error = parse_program(program_string).err().unwrap();
|
2020-11-12 21:28:24 +03:00
|
|
|
|
|
|
|
// Expect a type inference error.
|
2020-12-17 00:02:31 +03:00
|
|
|
crate::expect_asg_error(error);
|
2020-11-12 21:28:24 +03:00
|
|
|
}
|