mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
v.gen.c: support -d abort_on_assert
by injecting abort() calls
This commit is contained in:
parent
d90be54850
commit
f0c1e55637
@ -33,6 +33,9 @@ fn (mut g Gen) gen_assert_stmt(original_assert_statement ast.AssertStmt) {
|
||||
g.writeln('\tg_test_fails++;')
|
||||
metaname_fail := g.gen_assert_metainfo(node)
|
||||
g.writeln('\tmain__cb_assertion_failed(&$metaname_fail);')
|
||||
if 'abort_on_assert' in g.pref.compile_defines_all {
|
||||
g.writeln('\tabort();')
|
||||
}
|
||||
g.writeln('\tlongjmp(g_jump_buffer, 1);')
|
||||
g.writeln('\t// TODO')
|
||||
g.writeln('\t// Maybe print all vars in a test function if it fails?')
|
||||
@ -45,6 +48,9 @@ fn (mut g Gen) gen_assert_stmt(original_assert_statement ast.AssertStmt) {
|
||||
g.writeln(' {')
|
||||
metaname_panic := g.gen_assert_metainfo(node)
|
||||
g.writeln('\t__print_assert_failure(&$metaname_panic);')
|
||||
if 'abort_on_assert' in g.pref.compile_defines_all {
|
||||
g.writeln('\tabort();')
|
||||
}
|
||||
g.writeln('\tv_panic(_SLIT("Assertion failed..."));')
|
||||
g.writeln('}')
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user