[fine] Test for function return type mismatch
This commit is contained in:
parent
d893002ec2
commit
44bc072b04
4 changed files with 23 additions and 6 deletions
|
|
@ -259,7 +259,6 @@ fn assert_no_errors(tree: &SyntaxTree, lines: &Lines) {
|
|||
);
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn assert_eval_ok(tree: &SyntaxTree, lines: &Lines, expected: &str) {
|
||||
let semantics = Semantics::new(tree, lines);
|
||||
|
||||
|
|
@ -284,4 +283,17 @@ fn assert_eval_ok(tree: &SyntaxTree, lines: &Lines, expected: &str) {
|
|||
}
|
||||
}
|
||||
|
||||
fn assert_check_error(tree: &SyntaxTree, lines: &Lines, expected: &str) {
|
||||
let semantics = Semantics::new(tree, lines);
|
||||
check(&semantics);
|
||||
|
||||
let errors = semantics.snapshot_errors();
|
||||
semantic_assert!(
|
||||
&semantics,
|
||||
None,
|
||||
errors.iter().any(|e| e.message == expected),
|
||||
"Unable to find the expected error message '{expected}'"
|
||||
);
|
||||
}
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/generated_tests.rs"));
|
||||
|
|
|
|||
5
fine/tests/expression/errors/return_type_mismatch.fine
Normal file
5
fine/tests/expression/errors/return_type_mismatch.fine
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
fun test() -> bool {
|
||||
32
|
||||
}
|
||||
|
||||
// @check-error: the body of this function yields a value of type `f64`, but callers expect this function to produce a `bool`
|
||||
Loading…
Add table
Add a link
Reference in a new issue