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

checker: merge array_map_fn_err tests (#8507)

This commit is contained in:
yuyi 2021-02-03 17:26:26 +08:00 committed by GitHub
parent ea06966fd4
commit 9bcb57eb1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 71 additions and 70 deletions

View File

@ -1,6 +0,0 @@
vlib/v/checker/tests/array_map_anon_fn_err_a.vv:2:21: error: function needs exactly 1 argument
1 | fn main() {
2 | a := [1,2,3,4].map(fn(a int, b int) int {return a + b})
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 | println(a)
4 | }

View File

@ -1,4 +0,0 @@
fn main() {
a := [1,2,3,4].map(fn(a int, b int) int {return a + b})
println(a)
}

View File

@ -1,6 +0,0 @@
vlib/v/checker/tests/array_map_anon_fn_err_b.vv:2:21: error: type mismatch, should use `fn(a int) T {...}`
1 | fn main() {
2 | a := [1,2,3,4].map(fn(a string) string { return a })
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 | println(a)
4 | }

View File

@ -1,4 +0,0 @@
fn main() {
a := [1,2,3,4].map(fn(a string) string { return a })
println(a)
}

View File

@ -1,6 +0,0 @@
vlib/v/checker/tests/array_map_anon_fn_err_c.vv:2:21: error: type mismatch, should use `fn(a int) T {...}`
1 | fn main() {
2 | a := [1,2,3,4].map(fn(a string) {})
| ~~~~~~~~~~~~~~~
3 | println(a)
4 | }

View File

@ -1,4 +0,0 @@
fn main() {
a := [1,2,3,4].map(fn(a string) {})
println(a)
}

View File

@ -0,0 +1,41 @@
vlib/v/checker/tests/array_map_fn_err.vv:2:22: error: function needs exactly 1 argument
1 | fn main() {
2 | a1 := [1,2,3,4].map(fn(a int, b int) int {return a + b})
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 | println(a1)
4 |
vlib/v/checker/tests/array_map_fn_err.vv:5:22: error: type mismatch, should use `fn(a int) T {...}`
3 | println(a1)
4 |
5 | a2 := [1,2,3,4].map(fn(a string) string { return a })
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6 | println(a2)
7 |
vlib/v/checker/tests/array_map_fn_err.vv:8:22: error: type mismatch, should use `fn(a int) T {...}`
6 | println(a2)
7 |
8 | a3 := [1,2,3,4].map(fn(a string) {})
| ~~~~~~~~~~~~~~~
9 | println(a3)
10 |
vlib/v/checker/tests/array_map_fn_err.vv:11:18: error: function needs exactly 1 argument
9 | println(a3)
10 |
11 | a4 := [1,2,3,4].map(add1)
| ~~~~~~~~~
12 | println(a4)
13 |
vlib/v/checker/tests/array_map_fn_err.vv:14:22: error: type mismatch, should use `fn(a int) T {...}`
12 | println(a4)
13 |
14 | a5 := [1,2,3,4].map(add2)
| ~~~~
15 | println(a5)
16 |
vlib/v/checker/tests/array_map_fn_err.vv:17:22: error: type mismatch, should use `fn(a int) T {...}`
15 | println(a5)
16 |
17 | a6 := [1,2,3,4].map(do_nothing)
| ~~~~~~~~~~
18 | println(a6)
19 | }

View File

@ -0,0 +1,30 @@
fn main() {
a1 := [1,2,3,4].map(fn(a int, b int) int {return a + b})
println(a1)
a2 := [1,2,3,4].map(fn(a string) string { return a })
println(a2)
a3 := [1,2,3,4].map(fn(a string) {})
println(a3)
a4 := [1,2,3,4].map(add1)
println(a4)
a5 := [1,2,3,4].map(add2)
println(a5)
a6 := [1,2,3,4].map(do_nothing)
println(a6)
}
fn add1(a int, b int) int {
return a + b
}
fn add2(a string) string {
return a
}
fn do_nothing(a string) {
}

View File

@ -1,7 +0,0 @@
vlib/v/checker/tests/array_map_fn_err_a.vv:5:17: error: function needs exactly 1 argument
3 | }
4 | fn main() {
5 | a := [1,2,3,4].map(add)
| ~~~~~~~~
6 | println(a)
7 | }

View File

@ -1,7 +0,0 @@
fn add(a int, b int) int {
return a + b
}
fn main() {
a := [1,2,3,4].map(add)
println(a)
}

View File

@ -1,7 +0,0 @@
vlib/v/checker/tests/array_map_fn_err_b.vv:5:21: error: type mismatch, should use `fn(a int) T {...}`
3 | }
4 | fn main() {
5 | a := [1,2,3,4].map(add)
| ~~~
6 | println(a)
7 | }

View File

@ -1,7 +0,0 @@
fn add(a string) string {
return a
}
fn main() {
a := [1,2,3,4].map(add)
println(a)
}

View File

@ -1,7 +0,0 @@
vlib/v/checker/tests/array_map_fn_err_c.vv:3:21: error: type mismatch, should use `fn(a int) T {...}`
1 | fn do_nothing(a string) {}
2 | fn main() {
3 | a := [1,2,3,4].map(do_nothing)
| ~~~~~~~~~~
4 | println(a)
5 | }

View File

@ -1,5 +0,0 @@
fn do_nothing(a string) {}
fn main() {
a := [1,2,3,4].map(do_nothing)
println(a)
}