D string expression test.
This commit is contained in:
parent
2dd3bf5a06
commit
c94a698a52
@ -42,6 +42,31 @@ pub mod node {
|
||||
Self::new(vec![])
|
||||
}
|
||||
}
|
||||
|
||||
impl Expression {
|
||||
pub fn unwrap_identifier(&self) -> &Identifier {
|
||||
let primary = self.ternary_expression()
|
||||
.or_expression()
|
||||
.left()
|
||||
.left()
|
||||
.left()
|
||||
.left()
|
||||
.left()
|
||||
.left()
|
||||
.right()
|
||||
.left();
|
||||
match primary {
|
||||
PrimaryExpression::FullyQualifiedName(fqn) => {
|
||||
if fqn.identifiers().count() == 1 {
|
||||
fqn.identifiers().next().unwrap()
|
||||
} else {
|
||||
panic!()
|
||||
}
|
||||
}
|
||||
_ => panic!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod build {
|
||||
@ -56,6 +81,7 @@ pub mod build {
|
||||
|
||||
#[cfg(test)]
|
||||
mod build_tests {
|
||||
use std::process::id;
|
||||
use super::*;
|
||||
use crate::parser::DeimosParser;
|
||||
use pest::Parser;
|
||||
@ -102,5 +128,13 @@ pub mod build {
|
||||
assert_eq!(backtick_string.inners().count(), 2);
|
||||
assert_eq!(backtick_string.expressions().count(), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn d_string_expression_simple() {
|
||||
let pair = parse(Rule::DStringExpression, "${thing}");
|
||||
let d_string_expression = build_d_string_expression(pair);
|
||||
let identifier = d_string_expression.expression().unwrap_identifier();
|
||||
assert_eq!("thing", identifier.name());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user