[fine] Oh no a runtime and module loading and stuff
Lots of test work to use the new mechanism. I'm not sure I like it.
This commit is contained in:
parent
2093502031
commit
994268abb6
6 changed files with 224 additions and 90 deletions
|
|
@ -57,7 +57,7 @@ fn generate_test_for_file(path: PathBuf) -> String {
|
|||
}
|
||||
|
||||
assertions.push(quote! {
|
||||
crate::assert_concrete(source.clone(), _tree.clone(), #concrete, #display_path);
|
||||
crate::assert_concrete(source.clone(), #concrete, #display_path);
|
||||
});
|
||||
} else if line == "@compiles-to:" {
|
||||
let mut compiled = String::new();
|
||||
|
|
@ -72,7 +72,7 @@ fn generate_test_for_file(path: PathBuf) -> String {
|
|||
}
|
||||
|
||||
assertions.push(quote! {
|
||||
crate::assert_compiles_to(source.clone(), _tree.clone(), _lines.clone(), #compiled, #display_path);
|
||||
crate::assert_compiles_to(_module.clone(), #compiled, #display_path);
|
||||
});
|
||||
} else if let Some(line) = line.strip_prefix("@type:") {
|
||||
let (pos, expected) = line
|
||||
|
|
@ -85,7 +85,7 @@ fn generate_test_for_file(path: PathBuf) -> String {
|
|||
.expect(&format!("Unable to parse position '{pos}'"));
|
||||
let expected = expected.trim();
|
||||
assertions.push(quote! {
|
||||
crate::assert_type_at(source.clone(), _tree.clone(), _lines.clone(), #pos, #expected, #display_path);
|
||||
crate::assert_type_at(_module.clone(), #pos, #expected, #display_path);
|
||||
});
|
||||
} else if let Some(line) = line.strip_prefix("@type-error:") {
|
||||
let (pos, expected) = line
|
||||
|
|
@ -98,21 +98,21 @@ fn generate_test_for_file(path: PathBuf) -> String {
|
|||
.expect(&format!("Unable to parse position '{pos}'"));
|
||||
let expected = expected.trim();
|
||||
assertions.push(quote! {
|
||||
crate::assert_type_error_at(source.clone(), _tree.clone(), _lines.clone(), #pos, #expected, #display_path);
|
||||
crate::assert_type_error_at(_module.clone(), &_errors, #pos, #expected, #display_path);
|
||||
});
|
||||
} else if line == "@no-errors" {
|
||||
assertions.push(quote! {
|
||||
crate::assert_no_errors(source.clone(), _tree.clone(), _lines.clone());
|
||||
crate::assert_no_errors(_module.clone(), &_errors);
|
||||
});
|
||||
} else if let Some(line) = line.strip_prefix("@eval:") {
|
||||
let expected = line.trim();
|
||||
assertions.push(quote! {
|
||||
crate::assert_eval_ok(source.clone(), _tree.clone(), _lines.clone(), #expected);
|
||||
crate::assert_eval_ok(_module.clone(), #expected);
|
||||
});
|
||||
} else if let Some(line) = line.strip_prefix("@check-error:") {
|
||||
let expected = line.trim();
|
||||
assertions.push(quote! {
|
||||
crate::assert_check_error(source.clone(), _tree.clone(), _lines.clone(), #expected);
|
||||
crate::assert_check_error(_module.clone(), &_errors, #expected);
|
||||
});
|
||||
} else if line == "@expect-errors:" {
|
||||
let mut errors = Vec::new();
|
||||
|
|
@ -127,7 +127,7 @@ fn generate_test_for_file(path: PathBuf) -> String {
|
|||
|
||||
let errors = ExpectedErrors(errors);
|
||||
assertions.push(quote! {
|
||||
crate::assert_errors(source.clone(), _tree.clone(), _lines.clone(), #errors);
|
||||
crate::assert_errors(_module.clone(), &_errors, #errors);
|
||||
});
|
||||
} else if line.starts_with("@") {
|
||||
panic!("Test file {display_path} has unknown directive: {line}");
|
||||
|
|
@ -139,7 +139,9 @@ fn generate_test_for_file(path: PathBuf) -> String {
|
|||
#disabled
|
||||
fn #name() {
|
||||
let source : std::rc::Rc<str> = #contents.into();
|
||||
let (_tree, _lines) = fine::parser::parse(&source);
|
||||
let mut runtime = crate::test_runtime(source.clone());
|
||||
let (_errors, _module) = runtime.load_module("__test__").unwrap();
|
||||
|
||||
#(#assertions)*
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue