2020-10-21 12:49:41 -04:00
|
|
|
use super::super::error::Result;
|
2020-10-21 12:37:24 -04:00
|
|
|
use lazy_static::lazy_static;
|
|
|
|
|
use regex::Regex;
|
2020-10-21 12:56:11 -04:00
|
|
|
use std::fs;
|
2020-10-21 12:37:24 -04:00
|
|
|
use tree_sitter::Point;
|
|
|
|
|
|
|
|
|
|
// TODO: It would be cooler to do this with a comments query rather than with a regex
|
|
|
|
|
// directly.
|
|
|
|
|
lazy_static! {
|
|
|
|
|
static ref METADATA_PAIR_REGEX: Regex = Regex::new(r#"(\w+): ([^\s,]+)"#).unwrap();
|
|
|
|
|
static ref NUMBER_REGEX: Regex = Regex::new(r#"\d+"#).unwrap();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub struct CaptureInfo {
|
|
|
|
|
pub name: String,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Eq, PartialEq)]
|
|
|
|
|
struct Assertion {
|
|
|
|
|
position: Point,
|
|
|
|
|
line_numbers: Vec<usize>,
|
|
|
|
|
capture_type: String,
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-21 12:56:11 -04:00
|
|
|
pub fn assert_expected_captures(_captures: Vec<CaptureInfo>, path: String) -> Result<()> {
|
|
|
|
|
let contents = fs::read_to_string(path)?;
|
|
|
|
|
for m in METADATA_PAIR_REGEX.captures_iter(&contents) {
|
|
|
|
|
println!("pair: {:?}", m);
|
|
|
|
|
}
|
2020-10-21 12:49:41 -04:00
|
|
|
Ok(())
|
|
|
|
|
}
|