}
}
-#[derive(Debug, Clone)]
+#[derive(Debug, Clone, PartialEq)]
pub enum Source<'a> {
Str(&'a str),
Sub(Substitution<'a>),
}
-#[derive(Debug, Clone)]
+#[derive(Debug, Clone, PartialEq)]
pub enum Substitution<'a> {
Variable(&'a str),
Array(&'a str),
-use crate::parse_file;
+use crate::{parse_file, Source, Substitution};
use color_eyre::Result;
static SOURCE: &str = include_str!("test_source.meta");
+static PATTERN: &str = include_str!("test_pattern.meta");
#[test]
fn build_meta_file() -> Result<()> {
Ok(())
}
+
+#[test]
+fn build_pattern_file() -> Result<()> {
+ macro_rules! source (
+ (var($s:literal)) => { Source::Sub(Substitution::Variable($s))};
+ (arr($s:literal)) => { Source::Sub(Substitution::Array($s))};
+ (pat($s:literal)) => { Source::Sub(Substitution::Pattern($s))};
+ ($s:literal) => { Source::Str($s)};
+ );
+
+ let mut pattern_src = parse_file(PATTERN)?.source.into_iter();
+
+ pattern_src.next();
+ assert_eq!(pattern_src.next().unwrap(), source!(var("${var}")));
+ pattern_src.next();
+ assert_eq!(pattern_src.next().unwrap(), source!(pat("&{pat}")));
+ assert_eq!(pattern_src.next().unwrap(), source!(arr("@{array}")));
+ pattern_src.next();
+ assert_eq!(pattern_src.next().unwrap(), source!(var("${blank}")));
+
+ Ok(())
+}
--- /dev/null
+<body>
+ <h1>This is a test for pattern.meta files</h1>
+
+ <p> inserted variable: ${var}</p>
+
+ &{pat}
+
+ @{array}
+
+ <ul>
+ <li> with-{ inline comment} html </li>
+ <li> type syntax including :${blank} blank variables
+ <li> and symbols: !@$%#&*(){}
+ </ul>
+</body>