use super::{LexOptions, TestCallbacks, TokenEvent, lex_with, tokenize};
#[test]
fn triple_mustache_default_is_braced_interpolation_plus_text() {
let cb = tokenize("{{{ x }}}");
assert!(cb.errors.is_empty());
assert!(cb.events.contains(&TokenEvent::Interpolation(2, 6)));
assert!(cb.events.contains(&TokenEvent::Text(8, 9)));
assert!(
!cb.events
.iter()
.any(|e| matches!(e, TokenEvent::RawInterpolation(..))),
"no raw interpolation without the capability"
);
}
fn tokenize_triple(input: &str) -> TestCallbacks {
let options = LexOptions {
raw_interpolation: true,
..LexOptions::default()
};
lex_with(input, options)
}
#[test]
fn triple_mustache_with_capability_emits_raw_interpolation() {
let cb = tokenize_triple("{{{ x }}}");
assert!(cb.errors.is_empty(), "{:?}", cb.errors);
assert!(cb.events.contains(&TokenEvent::RawInterpolation(3, 6)));
assert!(
!cb.events.iter().any(|e| matches!(e, TokenEvent::Text(..))),
"no stray brace text: {:?}",
cb.events
);
}
#[test]
fn double_mustache_with_capability_is_unchanged() {
let cb = tokenize_triple("{{ x }}");
assert!(cb.errors.is_empty());
assert!(cb.events.contains(&TokenEvent::Interpolation(2, 5)));
assert!(
!cb.events
.iter()
.any(|e| matches!(e, TokenEvent::RawInterpolation(..))),
"`{{{{ … }}}}` stays a plain interpolation"
);
}
#[test]
fn triple_mustache_adjacent_and_mixed_with_text() {
let cb = tokenize_triple("a {{{ x }}} b");
assert!(cb.errors.is_empty());
assert!(cb.events.contains(&TokenEvent::Text(0, 2))); assert!(cb.events.contains(&TokenEvent::RawInterpolation(5, 8))); assert!(cb.events.contains(&TokenEvent::Text(11, 13))); }