mirror of
https://github.com/Dummi26/mers.git
synced 2025-12-24 15:36:33 +01:00
added basic tests
This commit is contained in:
1
mers/tests/return_true.mers
Normal file
1
mers/tests/return_true.mers
Normal file
@@ -0,0 +1 @@
|
||||
true
|
||||
24
mers/tests/test_in_mers.rs
Normal file
24
mers/tests/test_in_mers.rs
Normal 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)
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
3
mers/tests/type_syntax.mers
Normal file
3
mers/tests/type_syntax.mers
Normal file
@@ -0,0 +1,3 @@
|
||||
var: [string ...] = [...]
|
||||
&var.push("a string")
|
||||
var.len().eq(1)
|
||||
Reference in New Issue
Block a user