v test-self: check unsafe_test.v, match_test.v, match_in_fn_call_test.v with -cstrict

pull/10881/head
Delyan Angelov 2021-07-20 19:34:16 +03:00
parent 24c59881f5
commit d41a4ec662
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
4 changed files with 14 additions and 9 deletions

View File

@ -54,10 +54,7 @@ const (
'do_not_remove',
]
skip_with_werror = [
// -Wduplicated-branches
'vlib/v/tests/match_in_fn_call_test.v',
'vlib/v/tests/match_test.v',
'vlib/v/tests/unsafe_test.v',
'do_not_remove',
]
skip_with_asan_compiler = [
'do_not_remove',

View File

@ -10,17 +10,24 @@ fn make_result() []Data {
return []
}
// make_result2 is here to ensure that
// the branches contain different code,
// so the tests passes even with -cstrict -cc gcc
fn make_result2() []Data {
return []
}
fn f_doesnotcompile(d Data) []Data {
return match d.len() {
1 { make_result() }
else { make_result() }
else { make_result2() }
}
}
fn f_compiles1(d Data) []Data {
return match d.array.len {
1 { make_result() }
else { make_result() }
else { make_result2() }
}
}
@ -28,7 +35,7 @@ fn f_compiles2(d Data) []Data {
length := d.array.len
return match length {
1 { make_result() }
else { make_result() }
else { make_result2() }
}
}

View File

@ -139,7 +139,7 @@ fn test_method_call() {
1 { false }
2 { true }
3 { false }
else { false }
else { true }
}
}

View File

@ -54,7 +54,8 @@ fn test_funcs() {
fn test_if_expr_unsafe() {
i := 4
p := if true { unsafe { &i } } else { unsafe { &i } }
ii := 123
p := if true { unsafe { &i } } else { unsafe { &ii } }
assert *p == 4
}