Skip to content

Commit

Permalink
builtin: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
medvednikov committed Mar 29, 2024
1 parent acf0107 commit 24ac0c1
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion examples/sokol/06_obj_viewer/modules/obj/obj.v
Expand Up @@ -232,7 +232,7 @@ pub fn (mut obj_part ObjPart) parse_obj_buffer(rows []string, single_material bo
mat_count++
mut part := Part{}
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
}
part.name = obj_part.part[obj_part.part.len - 1].name[..li] +
Expand Down
12 changes: 6 additions & 6 deletions vlib/builtin/string_test.v
Expand Up @@ -1309,7 +1309,7 @@ fn test_string_literal_with_backslash_followed_by_newline() {
Five \\\\\
end'
assert b == 'One Two Three ${single_backslash}Four ${double_backslash}${newline} Five ${double_backslash}end'

// Note `\\` is followed *directly* by a newline, but `\\` is just an escape for `\`,
// and thus the newline has no special meaning, and should go into the string literal.
c := 'Hello\\
Expand Down Expand Up @@ -1481,11 +1481,11 @@ fn test_index_u8() {
}

fn test_index_last() {
assert 'abcabca'.index_last('ca')? == 5
assert 'abcabca'.index_last('ab')? == 3
assert 'abcabca'.index_last('b')? == 4
assert 'Zabcabca'.index_last('Z')? == 0
x := 'Zabcabca'.index_last('Y')
assert 'abcabca'.last_index('ca')? == 5
assert 'abcabca'.last_index('ab')? == 3
assert 'abcabca'.last_index('b')? == 4
assert 'Zabcabca'.last_index('Z')? == 0
x := 'Zabcabca'.last_index('Y')
assert x == none
// TODO: `assert 'Zabcabca'.index_last('Y') == none` is a cgen error, 2023/12/04
}
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/checker/tests/type_cast_option_err.out
@@ -1,5 +1,5 @@
vlib/v/checker/tests/type_cast_option_err.vv:2:10: error: cannot type cast an Option
1 | fn main() {
2 | println(int('hi'.index_last('i')))
2 | println(int('hi'.last_index('i')))
| ~~~~~~~~~~~~~~~~~~~~~~~~~
3 | }
2 changes: 1 addition & 1 deletion vlib/v/checker/tests/type_cast_option_err.vv
@@ -1,3 +1,3 @@
fn main() {
println(int('hi'.index_last('i')))
println(int('hi'.last_index('i')))
}
2 changes: 1 addition & 1 deletion vlib/v/tests/option_default_values_test.v
Expand Up @@ -127,7 +127,7 @@ fn test_nested_option_with_opt_fn_call_as_last_value() {

fn remove_suffix1(s string) string {
n := s.len
i := s.index_last('.') or { n }
i := s.last_index('.') or { n }
return s[0..i]
}

Expand Down

0 comments on commit 24ac0c1

Please sign in to comment.