mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: warn if fn looks like a test fn but filename doesn't end in _test.v
(#6469)
This commit is contained in:
parent
ffee3791e8
commit
fbae0a7274
@ -3919,6 +3919,18 @@ fn (mut c Checker) fn_decl(mut node ast.FnDecl) {
|
||||
c.error('.str() methods should have 0 arguments', node.pos)
|
||||
}
|
||||
}
|
||||
// TODO c.pref.is_vet
|
||||
if node.language == .v && !node.is_method && node.args.len == 0 && node.return_type == table.void_type_idx &&
|
||||
node.name.after('.').starts_with('test_') && !c.file.path.ends_with('_test.v') {
|
||||
// simple heuristic
|
||||
for st in node.stmts {
|
||||
if st is ast.AssertStmt {
|
||||
c.warn('tests will not be run because filename does not end with `_test.v`',
|
||||
node.pos)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
c.expected_type = table.void_type
|
||||
c.cur_fn = node
|
||||
// Add return if `fn(...) ? {...}` have no return at end
|
||||
|
Loading…
Reference in New Issue
Block a user