Skip to content

Commit

Permalink
improve test
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Sep 12, 2024
1 parent 2c4b289 commit e6ced9b
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions vlib/v/tests/indexexpr_with_assign_test.v
Original file line number Diff line number Diff line change
@@ -1,11 +1,34 @@
fn test_main() {
fn test_1() {
mut test := []f64{}
test << 0
test[0] = if true {
sum := 0.0
sum := 1.2
sum
} else {
0
}
assert test == [0.0]
assert test == [1.2]
}

fn test_2() {
check := true
mut test := []f64{len: 100}
for i in 0 .. 100 {
test[i] = if check {
mut sum := 0.0
for x in 0 .. 100 {
if check {
sum += 1
}
if i <= x {
break
}
}
sum
} else {
0
}
}
assert test[0] == 1.0
assert test[99] == 100.0
}

0 comments on commit e6ced9b

Please sign in to comment.