use rdxl::{xhtml,xtext};
fn bs(s: String) -> String {
s.split_whitespace().collect::>().join(" ")
}
#[test]
fn breaking_for() {
assert_eq!(
&bs(xhtml!(
- 1
- {{ 2 }}
{{ for i in 3..5 {{
- {{ i }}
}} }}
)),
""
);
}
#[test]
fn nonbreaking_for() {
assert_eq!(
&xtext!(
- 1
- {{ 2 }}
{{ for i in 3..5 {{
- {{ i }}
}} }}
),
""
);
}
#[test]
fn breaking_while() {
assert_eq!(
&bs(xhtml!(
{{ let mut i = 3; }}
{{ while i>0 {{
- {{ i }}
{{ i -= 1; }}
}} }}
)),
""
);
}
#[test]
fn nonbreaking_while() {
assert_eq!(
&xtext!(
{{ let mut i = 3; }}
{{ while i>0 {{
- {{ i }}
{{ i -= 1; }}
}} }}
),
""
);
}
#[test]
fn breaking_if() {
assert_eq!(
&bs(xhtml!(
{{ let x = 5; }}
{{ if x>4 {{
- 1
}} }}
{{ if x<4 {{
- 1
}} else if x>4 {{
- 2
}} }}
{{ if x<4 {{
- 1
}} else {{
- 3
}} }}
)),
""
);
}
#[test]
fn nonbreaking_if() {
assert_eq!(
&xtext!(
{{ let x = 5; }}
{{ if x>4 {{
- 1
}} }}
{{ if x<4 {{
- 1
}} else if x>4 {{
- 2
}} }}
{{ if x<4 {{
- 1
}} else {{
- 3
}} }}
),
""
);
}
#[test]
fn nonbreaking_lex2() {
assert_eq!(
xhtml!(macro),
"macro"
);
}