builtin: fix tests

This commit is contained in:
Alexander Medvednikov 2024-03-29 07:59:11 +03:00
parent acf0107493
commit 24ac0c1fb5
5 changed files with 10 additions and 10 deletions

View file

@ -232,7 +232,7 @@ pub fn (mut obj_part ObjPart) parse_obj_buffer(rows []string, single_material bo
mat_count++ mat_count++
mut part := Part{} mut part := Part{}
if mat_count > 1 { if mat_count > 1 {
li := obj_part.part[obj_part.part.len - 1].name.index_last('_m') or { li := obj_part.part[obj_part.part.len - 1].name.last_index('_m') or {
obj_part.part[obj_part.part.len - 1].name.len - 1 obj_part.part[obj_part.part.len - 1].name.len - 1
} }
part.name = obj_part.part[obj_part.part.len - 1].name[..li] + part.name = obj_part.part[obj_part.part.len - 1].name[..li] +

View file

@ -1481,11 +1481,11 @@ fn test_index_u8() {
} }
fn test_index_last() { fn test_index_last() {
assert 'abcabca'.index_last('ca')? == 5 assert 'abcabca'.last_index('ca')? == 5
assert 'abcabca'.index_last('ab')? == 3 assert 'abcabca'.last_index('ab')? == 3
assert 'abcabca'.index_last('b')? == 4 assert 'abcabca'.last_index('b')? == 4
assert 'Zabcabca'.index_last('Z')? == 0 assert 'Zabcabca'.last_index('Z')? == 0
x := 'Zabcabca'.index_last('Y') x := 'Zabcabca'.last_index('Y')
assert x == none assert x == none
// TODO: `assert 'Zabcabca'.index_last('Y') == none` is a cgen error, 2023/12/04 // TODO: `assert 'Zabcabca'.index_last('Y') == none` is a cgen error, 2023/12/04
} }

View file

@ -1,5 +1,5 @@
vlib/v/checker/tests/type_cast_option_err.vv:2:10: error: cannot type cast an Option vlib/v/checker/tests/type_cast_option_err.vv:2:10: error: cannot type cast an Option
1 | fn main() { 1 | fn main() {
2 | println(int('hi'.index_last('i'))) 2 | println(int('hi'.last_index('i')))
| ~~~~~~~~~~~~~~~~~~~~~~~~~ | ~~~~~~~~~~~~~~~~~~~~~~~~~
3 | } 3 | }

View file

@ -1,3 +1,3 @@
fn main() { fn main() {
println(int('hi'.index_last('i'))) println(int('hi'.last_index('i')))
} }

View file

@ -127,7 +127,7 @@ fn test_nested_option_with_opt_fn_call_as_last_value() {
fn remove_suffix1(s string) string { fn remove_suffix1(s string) string {
n := s.len n := s.len
i := s.index_last('.') or { n } i := s.last_index('.') or { n }
return s[0..i] return s[0..i]
} }