leo/ast/tests/expression.rs
ljedrz 0ccaea86f7 test: introduce AST pest tests
Signed-off-by: ljedrz <ljedrz@gmail.com>
2020-10-14 10:37:39 +02:00

40 lines
1.0 KiB
Rust

use leo_ast::ast::{LanguageParser, Rule};
use pest::*;
#[test]
fn redundant_parens() {
parses_to! {
parser: LanguageParser,
input: "(true)",
rule: Rule::expression,
tokens: [
expression(0, 6, [
expression_term(0, 6, [expression(1, 5, [expression_term(1, 5, [value(1, 5, [value_boolean(1, 5, [])])])])])
])
]
}
}
#[test]
fn multiple_redundant_parens() {
parses_to! {
parser: LanguageParser,
input: "(((true)))",
rule: Rule::expression,
tokens: [
expression(0, 10, [
expression_term(0, 10, [
expression(1, 9, [expression_term(1, 9, [
expression(2, 8, [expression_term(2, 8, [
expression(3, 7, [expression_term(3, 7, [
value(3, 7, [value_boolean(3, 7, [])])
])])
])])
])])
])
])
]
}
}