mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
builtin: fix tests
This commit is contained in:
parent
acf0107493
commit
24ac0c1fb5
5 changed files with 10 additions and 10 deletions
|
@ -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] +
|
||||||
|
|
|
@ -1309,7 +1309,7 @@ fn test_string_literal_with_backslash_followed_by_newline() {
|
||||||
Five \\\\\
|
Five \\\\\
|
||||||
end'
|
end'
|
||||||
assert b == 'One Two Three ${single_backslash}Four ${double_backslash}${newline} Five ${double_backslash}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 `\`,
|
// 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.
|
// and thus the newline has no special meaning, and should go into the string literal.
|
||||||
c := 'Hello\\
|
c := 'Hello\\
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 | }
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
fn main() {
|
fn main() {
|
||||||
println(int('hi'.index_last('i')))
|
println(int('hi'.last_index('i')))
|
||||||
}
|
}
|
||||||
|
|
|
@ -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]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue