Skip to content

Commit e0488d3

Browse files
committed
Fix arrayFill test
1 parent 48e5cc3 commit e0488d3

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

usvm-ts/src/test/kotlin/org/usvm/samples/arrays/ArrayMethods.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,14 @@ class ArrayMethods : TsMethodTestRunner() {
4343
@Test
4444
fun testArrayFill() {
4545
val method = getMethod(className, "arrayFill")
46-
discoverProperties<TsTestValue.TsArray<TsTestValue.TsNumber>>(
46+
discoverProperties<TsTestValue.TsBoolean, TsTestValue.TsArray<TsTestValue.TsNumber>>(
4747
method = method,
48-
{ r ->
49-
r.values.map { it.number } == listOf(7.0, 7.0, 7.0)
48+
// Note: both branches return the same array (filled and modified original).
49+
{ x, r ->
50+
x.value && r.values.map { it.number } == listOf(7.0, 7.0, 7.0)
51+
},
52+
{ x, r ->
53+
!x.value && r.values.map { it.number } == listOf(7.0, 7.0, 7.0)
5054
},
5155
)
5256
}

usvm-ts/src/test/resources/samples/arrays/ArrayMethods.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,14 @@ class ArrayMethods {
2222
}
2323
}
2424

25-
arrayFill() {
25+
arrayFill(x: boolean) {
2626
let arr = [10, 20, 30];
27-
arr.fill(7);
28-
return arr; // [7, 7, 7]
27+
let filled = arr.fill(7);
28+
if (x) {
29+
return filled; // [7, 7, 7]
30+
} else {
31+
return arr; // [7, 7, 7] - modified in place
32+
}
2933
}
3034

3135
arrayShift(x: boolean) {

0 commit comments

Comments
 (0)