added basic tests

This commit is contained in:
mark
2023-04-30 22:21:27 +02:00
parent 657f282006
commit b83f54cb2d
12 changed files with 103 additions and 36 deletions

View File

@@ -0,0 +1 @@
true

View File

@@ -0,0 +1,24 @@
use std::{fs, path::Path};
use mers_libs::file::File;
use mers_libs::{parse, VDataEnum};
#[test]
fn run_all() {
for file in fs::read_dir(Path::new(file!()).parent().unwrap())
.unwrap()
.filter_map(|v| v.ok())
{
if let Some(file_name) = file.file_name().to_str() {
if file_name.ends_with(".mers") {
eprintln!("Checking {}", file_name);
let mut file = File::new(fs::read_to_string(file.path()).unwrap(), file.path());
// has to return true, otherwise the test will fail
assert!(matches!(
parse::parse(&mut file).unwrap().run(vec![]).data,
VDataEnum::Bool(true)
));
}
}
}
}

View File

@@ -0,0 +1,3 @@
var: [string ...] = [...]
&var.push("a string")
var.len().eq(1)