Skip to content

Commit 277c9c5

Browse files
committed
tests: add 2 simpler tests, to isolate a s390x failure
1 parent d106ad6 commit 277c9c5

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
fn vectorize(op fn (f64) f64) fn ([]f64) []f64 {
2+
return fn [op] (values []f64) []f64 {
3+
mut result := []f64{len: values.len}
4+
for i in 0 .. values.len {
5+
result[i] = op(values[i])
6+
}
7+
return result
8+
}
9+
}
10+
11+
fn add_one(x f64) f64 {
12+
return x + 1
13+
}
14+
15+
fn test_return_generic_closure_f64() {
16+
vadd1 := vectorize(add_one)
17+
v1 := [1.0, 2, 3, 4]
18+
println(vadd1(v1))
19+
assert vadd1(v1) == [2.0, 3, 4, 5]
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
fn vectorize(op fn (int) int) fn ([]int) []int {
2+
return fn [op] (values []int) []int {
3+
mut result := []int{len: values.len}
4+
for i in 0 .. values.len {
5+
result[i] = op(values[i])
6+
}
7+
return result
8+
}
9+
}
10+
11+
fn add_one(x int) int {
12+
return x + 1
13+
}
14+
15+
fn test_return_generic_closure_int() {
16+
vadd1 := vectorize(add_one)
17+
v1 := [1, 2, 3, 4]
18+
println(vadd1(v1))
19+
assert vadd1(v1) == [2, 3, 4, 5]
20+
}

0 commit comments

Comments
 (0)