1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

all: change optional to result in most of the libraries (#16123)

This commit is contained in:
yuyi
2022-10-21 03:14:33 +08:00
committed by GitHub
parent 0d368562f4
commit 51f4d99399
75 changed files with 439 additions and 446 deletions

View File

@ -358,11 +358,11 @@ fn test_shuffle_partial() {
mut a := [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
mut b := a.clone()
rand.shuffle(mut a, start: 4)?
rand.shuffle(mut a, start: 4)!
assert a[..4] == b[..4]
a = b.clone()
rand.shuffle(mut a, start: 3, end: 7)?
rand.shuffle(mut a, start: 3, end: 7)!
assert a[..3] == b[..3]
assert a[7..] == b[7..]
}
@ -386,7 +386,7 @@ fn test_choose() {
lengths := [1, 3, 4, 5, 6, 7]
a := ['one', 'two', 'three', 'four', 'five', 'six', 'seven']
for length in lengths {
b := rand.choose(a, length)?
b := rand.choose(a, length)!
assert b.len == length
for element in b {
assert element in a
@ -415,7 +415,7 @@ fn test_sample() {
fn test_element1() {
a := ['one', 'two', 'four', 'five', 'six', 'seven']
for _ in 0 .. 30 {
e := rand.element(a)?
e := rand.element(a)!
assert e in a
assert 'three' != e
}
@ -423,7 +423,7 @@ fn test_element1() {
fn test_element2() {
for _ in 0 .. 30 {
e := rand.element([1, 2, 5, 6, 7, 8])?
e := rand.element([1, 2, 5, 6, 7, 8])!
assert e in [1, 2, 5, 6, 7, 8]
assert 3 != e
assert 4 != e