leo/grammar/tests/deprecated.rs

57 lines
1.8 KiB
Rust
Raw Normal View History

2021-02-02 07:26:56 +03:00
// Copyright (C) 2019-2021 Aleo Systems Inc.
2021-01-21 23:30: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/>.
use leo_grammar::ast::{LanguageParser, Rule};
use pest::*;
#[test]
2021-01-27 20:10:34 +03:00
fn test_deprecated_test_function() {
2021-01-21 23:30:26 +03:00
parses_to! {
parser: LanguageParser,
2021-01-27 20:10:34 +03:00
input: r#"test function old() {
return ()
}"#,
rule: Rule::deprecated,
2021-01-21 23:30:26 +03:00
tokens: [
2021-01-27 20:10:34 +03:00
deprecated(0, 37, [
test_function(0, 37, [
function(5, 37, [
identifier(14, 17, []),
block(20, 37, [
statement(26, 36, [
statement_return(26, 36, [expression(33, 36, [expression_term(33, 35, [expression_tuple(33, 35, [])])])])
])
])
])
])
])
2021-01-21 23:30:26 +03:00
]
}
}
#[test]
2021-01-27 20:10:34 +03:00
fn test_deprecated_context_function() {
2021-01-21 23:30:26 +03:00
parses_to! {
parser: LanguageParser,
2021-01-27 20:10:34 +03:00
input: "@context(custom)",
2021-01-21 23:30:26 +03:00
rule: Rule::annotation,
tokens: [
2021-01-27 20:10:34 +03:00
annotation(0, 16, [annotation_symbol(0, 1, []), annotation_name(1, 8, [context(1, 8, [])]), annotation_arguments(8, 16, [annotation_argument(9, 15, [])])])
2021-01-21 23:30:26 +03:00
]
}
}