checker: reorganize tests to match fmt tests

pull/4605/head
Enzo Baldisserri 2020-04-26 12:34:42 +02:00 committed by GitHub
parent 41eb4453e3
commit 0f2f97e3e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
279 changed files with 931 additions and 424 deletions

View File

@ -360,6 +360,17 @@ pub fn (mut c Checker) infix_expr(infix_expr mut ast.InfixExpr) table.Type {
.left_shift {
if left.kind == .array {
// `array << elm`
match infix_expr.left {
ast.Ident {
}
ast.SelectorExpr {
}
else {
println('typeof: ${typeof(infix_expr.left)}')
}
}
// the expressions have different types (array_x and x)
if c.table.check(c.table.value_type(left_type), right_type) {
// []T << T

View File

@ -5,7 +5,7 @@ fn test_all() {
mut total_errors := 0
vexe := os.getenv('VEXE')
// vroot := os.dir(vexe)
dir := 'vlib/v/checker/tests/inout'
dir := 'vlib/v/checker/tests'
files := os.ls(dir) or {
panic(err)
}

View File

@ -0,0 +1,6 @@
vlib/v/checker/tests/add_op_wrong_left_type_err_a.v:3:5: error: mismatched types `A` and `int`
1| struct A{}
2| fn main() {
3| A{} + 10
~~~
4| }

View File

@ -0,0 +1,4 @@
struct A{}
fn main() {
A{} + 10
}

View File

@ -0,0 +1,5 @@
vlib/v/checker/tests/add_op_wrong_left_type_err_b.v:2:5: error: mismatched types `array_int` and `int`
1| fn main() {
2| [1,2,3] + 10
~~~~~~~
3| }

View File

@ -0,0 +1,3 @@
fn main() {
[1,2,3] + 10
}

View File

@ -0,0 +1,6 @@
vlib/v/checker/tests/add_op_wrong_left_type_err_c.v:3:5: error: mismatched types `map_string_int` and `int`
1| fn main() {
2| a := map[string]int
3| a + 10
^
4| }

View File

@ -0,0 +1,4 @@
fn main() {
a := map[string]int
a + 10
}

View File

@ -0,0 +1,6 @@
vlib/v/checker/tests/add_op_wrong_right_type_err_a.v:3:10: error: mismatched types `int` and `A`
1| struct A{}
2| fn main() {
3| 10 + A{}
~~~
4| }

View File

@ -0,0 +1,4 @@
struct A{}
fn main() {
10 + A{}
}

View File

@ -0,0 +1,5 @@
vlib/v/checker/tests/add_op_wrong_right_type_err_b.v:2:10: error: mismatched types `int` and `array_int`
1| fn main() {
2| 10 + [1,2,3]
~~~~~~~
3| }

View File

@ -0,0 +1,3 @@
fn main() {
10 + [1,2,3]
}

View File

@ -0,0 +1,6 @@
vlib/v/checker/tests/add_op_wrong_right_type_err_c.v:3:10: error: mismatched types `int` and `map_string_int`
1| fn main() {
2| a := map[string]int
3| 10 + a
^
4| }

View File

@ -0,0 +1,4 @@
fn main() {
a := map[string]int
10 + a
}

View File

@ -0,0 +1,5 @@
vlib/v/checker/tests/alias_type_exists.v:1:1: error: type `Bird` doesn't exist
1| type Pigeon Bird
~~~~~~~~~~~
2|
3| fn main() {

View File

@ -0,0 +1,5 @@
type Pigeon Bird
fn main() {
}

View File

@ -0,0 +1,6 @@
vlib/v/checker/tests/assign_expr_type_err_a.v:3:2: error: operator <<= not defined on left operand type `f64`
1| fn main() {
2| mut foo := 0.5
3| foo <<= 1
~~~
4| }

View File

@ -0,0 +1,4 @@
fn main() {
mut foo := 0.5
foo <<= 1
}

View File

@ -1,4 +1,4 @@
fn main() {
mut foo := 0.5
foo <<= 1
fn main() {
mut foo := 0.5
foo <<= 1
}

View File

@ -0,0 +1,6 @@
vlib/v/checker/tests/assign_expr_type_err_b.v:3:9: error: operator %= not defined on right operand type `string`
1| fn main() {
2| mut foo := 10
3| foo %= 'hello'
~~~~~~~
4| }

View File

@ -0,0 +1,4 @@
fn main() {
mut foo := 10
foo %= 'hello'
}

View File

@ -1,4 +1,4 @@
fn main() {
mut foo := 10
foo %= 'hello'
fn main() {
mut foo := 10
foo %= 'hello'
}

View File

@ -0,0 +1,6 @@
vlib/v/checker/tests/assign_expr_type_err_c.v:3:2: error: operator *= not defined on left operand type `string`
1| fn main() {
2| mut foo := 'hello'
3| foo *= 10
~~~
4| }

View File

@ -0,0 +1,4 @@
fn main() {
mut foo := 'hello'
foo *= 10
}

View File

@ -1,4 +1,4 @@
fn main() {
mut foo := 'hello'
foo *= 10
fn main() {
mut foo := 'hello'
foo *= 10
}

View File

@ -0,0 +1,6 @@
vlib/v/checker/tests/assign_expr_type_err_d.v:3:9: error: operator /= not defined on right operand type `bool`
1| fn main() {
2| mut foo := 1.5
3| foo /= true
~~~~
4| }

View File

@ -0,0 +1,4 @@
fn main() {
mut foo := 1.5
foo /= true
}

View File

@ -1,4 +1,4 @@
fn main() {
mut foo := 1.5
foo /= true
fn main() {
mut foo := 1.5
foo /= true
}

View File

@ -0,0 +1,6 @@
vlib/v/checker/tests/assign_expr_type_err_e.v:3:2: error: operator -= not defined on left operand type `string`
1| fn main() {
2| mut foo := 'hello'
3| foo -= `a`
~~~
4| }

View File

@ -0,0 +1,4 @@
fn main() {
mut foo := 'hello'
foo -= `a`
}

View File

@ -1,4 +1,4 @@
fn main() {
mut foo := 'hello'
foo -= `a`
fn main() {
mut foo := 'hello'
foo -= `a`
}

View File

@ -0,0 +1,6 @@
vlib/v/checker/tests/assign_expr_type_err_f.v:3:9: error: operator -= not defined on right operand type `bool`
1| fn main() {
2| mut foo := 10
3| foo -= false
~~~~~
4| }

View File

@ -0,0 +1,4 @@
fn main() {
mut foo := 10
foo -= false
}

View File

@ -1,4 +1,4 @@
fn main() {
mut foo := 10
foo -= false
fn main() {
mut foo := 10
foo -= false
}

View File

@ -0,0 +1,6 @@
vlib/v/checker/tests/assign_expr_type_err_g.v:3:2: error: operator += not defined on left operand type `bool`
1| fn main() {
2| mut foo := true
3| foo += false
~~~
4| }

View File

@ -0,0 +1,4 @@
fn main() {
mut foo := true
foo += false
}

View File

@ -1,4 +1,4 @@
fn main() {
mut foo := true
foo += false
fn main() {
mut foo := true
foo += false
}

View File

@ -0,0 +1,6 @@
vlib/v/checker/tests/assign_expr_type_err_h.v:3:9: error: operator += not defined on right operand type `bool`
1| fn main() {
2| mut foo := 'hello'
3| foo += false
~~~~~
4| }

View File

@ -0,0 +1,4 @@
fn main() {
mut foo := 'hello'
foo += false
}

View File

@ -1,4 +1,4 @@
fn main() {
mut foo := 'hello'
foo += false
fn main() {
mut foo := 'hello'
foo += false
}

View File

@ -0,0 +1,6 @@
vlib/v/checker/tests/assign_expr_type_err_i.v:3:9: error: cannot assign `string` to variable `foo` of type `f64`
1| fn main() {
2| mut foo := 1.5
3| foo += 'hello'
~~~~~~~
4| }

View File

@ -0,0 +1,4 @@
fn main() {
mut foo := 1.5
foo += 'hello'
}

View File

@ -1,4 +1,4 @@
fn main() {
mut foo := 1.5
foo += 'hello'
fn main() {
mut foo := 1.5
foo += 'hello'
}

View File

@ -0,0 +1,5 @@
vlib/v/checker/tests/bit_op_wrong_left_type_err.v:2:2: error: left type of `&` cannot be non-integer type f64
1| fn main() {
2| 0.5 & 1
~~~
3| }

View File

@ -0,0 +1,3 @@
fn main() {
0.5 & 1
}

View File

@ -0,0 +1,5 @@
vlib/v/checker/tests/bit_op_wrong_right_type_err.v:2:6: error: right type of `|` cannot be non-integer type f64
1| fn main() {
2| 1 | 0.5
~~~
3| }

View File

@ -0,0 +1,3 @@
fn main() {
1 | 0.5
}

View File

@ -1,4 +1,4 @@
vlib/v/checker/tests/inout/cannot_assign_array.v:9:11: error: cannot assign `array_fixed_f64_8` to variable `ctx.vb` of type `string`
vlib/v/checker/tests/cannot_assign_array.v:9:11: error: cannot assign `array_fixed_f64_8` to variable `ctx.vb` of type `string`
7| mut ctx := Context{}
8| x := 2.32
9| ctx.vb = [1.1, x, 3.3, 4.4, 5.0, 6.0, 7.0, 8.9]!!

View File

@ -0,0 +1,10 @@
struct Context {
pub mut:
vb string
}
fn main() {
mut ctx := Context{}
x := 2.32
ctx.vb = [1.1, x, 3.3, 4.4, 5.0, 6.0, 7.0, 8.9]!!
}

View File

@ -0,0 +1,5 @@
vlib/v/checker/tests/decl_underscore.v:2:2: error: variable names cannot start with `__`
1| fn main() {
2| __abc := 1
~~~~~
3| }

View File

@ -0,0 +1,3 @@
fn main() {
__abc := 1
}

View File

@ -0,0 +1,6 @@
vlib/v/checker/tests/div_op_wrong_left_type_err_a.v:3:5: error: mismatched types `A` and `int`
1| struct A{}
2| fn main() {
3| A{} / 10
~~~
4| }

View File

@ -0,0 +1,4 @@
struct A{}
fn main() {
A{} / 10
}

View File

@ -0,0 +1,5 @@
vlib/v/checker/tests/div_op_wrong_left_type_err_b.v:2:5: error: mismatched types `array_int` and `int`
1| fn main() {
2| [1,2,3] / 10
~~~~~~~
3| }

View File

@ -0,0 +1,3 @@
fn main() {
[1,2,3] / 10
}

View File

@ -0,0 +1,6 @@
vlib/v/checker/tests/div_op_wrong_left_type_err_c.v:3:5: error: mismatched types `map_string_int` and `int`
1| fn main() {
2| a := map[string]int
3| a / 10
^
4| }

View File

@ -0,0 +1,4 @@
fn main() {
a := map[string]int
a / 10
}

View File

@ -0,0 +1,6 @@
vlib/v/checker/tests/div_op_wrong_right_type_err_a.v:3:10: error: mismatched types `int` and `A`
1| struct A{}
2| fn main() {
3| 10 / A{}
~~~
4| }

View File

@ -0,0 +1,4 @@
struct A{}
fn main() {
10 / A{}
}

View File

@ -0,0 +1,5 @@
vlib/v/checker/tests/div_op_wrong_right_type_err_b.v:2:10: error: mismatched types `int` and `array_int`
1| fn main() {
2| 10 / [1,2,3]
~~~~~~~
3| }

View File

@ -0,0 +1,3 @@
fn main() {
10 / [1,2,3]
}

View File

@ -0,0 +1,6 @@
vlib/v/checker/tests/div_op_wrong_right_type_err_c.v:3:10: error: mismatched types `int` and `map_string_int`
1| fn main() {
2| a := map[string]int
3| 10 / a
^
4| }

View File

@ -0,0 +1,4 @@
fn main() {
a := map[string]int
10 / a
}

View File

@ -1,11 +1,11 @@
vlib/v/checker/tests/inout/enum_err.v:4:13: error: default value for enum has to be an integer
2|
vlib/v/checker/tests/enum_err.v:4:13: error: default value for enum has to be an integer
2|
3| enum Color {
4| green = 'green',
~~~~~~~
5| yellow = 1+1,
6| blue,
vlib/v/checker/tests/inout/enum_err.v:5:14: error: default value for enum has to be an integer
vlib/v/checker/tests/enum_err.v:5:14: error: default value for enum has to be an integer
3| enum Color {
4| green = 'green',
5| yellow = 1+1,

View File

@ -0,0 +1,11 @@
module main
enum Color {
green = 'green',
yellow = 1+1,
blue,
}
fn main(){
println('hello')
}

View File

@ -1,9 +1,9 @@
vlib/v/checker/tests/inout/fn_type_exists.v:1:1: error: type `Pants` doesn't exist
vlib/v/checker/tests/fn_type_exists.v:1:1: error: type `Pants` doesn't exist
1| type PantsCreator = fn (a Shirt) Pants
~~~~~~~~~~~~~~~~~
2|
3| type PantsConsumer = fn (p Pants)
vlib/v/checker/tests/inout/fn_type_exists.v:3:1: error: type `Pants` doesn't exist
vlib/v/checker/tests/fn_type_exists.v:3:1: error: type `Pants` doesn't exist
1| type PantsCreator = fn (a Shirt) Pants
2|
3| type PantsConsumer = fn (p Pants)

View File

@ -0,0 +1,7 @@
type PantsCreator = fn (a Shirt) Pants
type PantsConsumer = fn (p Pants)
fn main() {
}

View File

@ -0,0 +1,6 @@
vlib/v/checker/tests/for-in-index-type.v:2:11: error: for in: cannot index `int`
1| fn main() {
2| for a in 52 {
~~
3| println(a)
4| }

View File

@ -0,0 +1,5 @@
fn main() {
for a in 52 {
println(a)
}
}

View File

@ -0,0 +1,6 @@
vlib/v/checker/tests/for_in_range_not_match_type.v:2:11: error: range types do not match
1| fn main() {
2| for i in 10..10.5 {
~~
3| println(i)
4| }

View File

@ -0,0 +1,5 @@
fn main() {
for i in 10..10.5 {
println(i)
}
}

View File

@ -0,0 +1,6 @@
vlib/v/checker/tests/for_in_range_string_type.v:2:11: error: range type can not be string
1| fn main() {
2| for i in 'a'..'b' {
~~~
3| println(i)
4| }

View File

@ -0,0 +1,5 @@
fn main() {
for i in 'a'..'b' {
println(i)
}
}

View File

@ -0,0 +1,5 @@
vlib/v/checker/tests/go_expr.v:2:5: error: expression in `go` must be a function call
1| fn main() {
2| go 1
^
3| }

View File

@ -0,0 +1,3 @@
fn main() {
go 1
}

View File

@ -1,53 +1,53 @@
vlib/v/checker/tests/inout/in_mismatch_type.v:13:7: error: the data type on the left of `in` does not match the array item type
vlib/v/checker/tests/in_mismatch_type.v:13:7: error: the data type on the left of `in` does not match the array item type
11| }
12| s := 'abcd'
13| if 1 in a_s {
~~
14| println('ok')
15| }
vlib/v/checker/tests/inout/in_mismatch_type.v:16:7: error: the data type on the left of `in` does not match the map key type
vlib/v/checker/tests/in_mismatch_type.v:16:7: error: the data type on the left of `in` does not match the map key type
14| println('ok')
15| }
16| if 2 in m {
~~
17| println('yeah')
18| }
vlib/v/checker/tests/inout/in_mismatch_type.v:19:7: error: the data type on the left of `in` must be a string
vlib/v/checker/tests/in_mismatch_type.v:19:7: error: the data type on the left of `in` must be a string
17| println('yeah')
18| }
19| if 3 in s {
~~
20| println('dope')
21| }
vlib/v/checker/tests/inout/in_mismatch_type.v:22:9: error: the data type on the left of `in` must be a string
vlib/v/checker/tests/in_mismatch_type.v:22:9: error: the data type on the left of `in` must be a string
20| println('dope')
21| }
22| if `a` in s {
~~
23| println("oh no :'(")
24| }
vlib/v/checker/tests/inout/in_mismatch_type.v:25:7: error: `in` can only be used with an array/map/string
vlib/v/checker/tests/in_mismatch_type.v:25:7: error: `in` can only be used with an array/map/string
23| println("oh no :'(")
24| }
25| if 1 in 12 {
~~
26| println('right')
27| }
vlib/v/checker/tests/inout/in_mismatch_type.v:28:12: error: the data type on the left of `in` does not match the map key type
vlib/v/checker/tests/in_mismatch_type.v:28:12: error: the data type on the left of `in` does not match the map key type
26| println('right')
27| }
28| if Int(2) in m {
~~
29| println('yeah')
30| }
vlib/v/checker/tests/inout/in_mismatch_type.v:31:15: error: the data type on the left of `in` does not match the array item type
vlib/v/checker/tests/in_mismatch_type.v:31:15: error: the data type on the left of `in` does not match the array item type
29| println('yeah')
30| }
31| if Str2('3') in a_i {
~~
32| println('sure')
33| }
vlib/v/checker/tests/inout/in_mismatch_type.v:34:15: error: the data type on the left of `in` does not match the array item type
vlib/v/checker/tests/in_mismatch_type.v:34:15: error: the data type on the left of `in` does not match the array item type
32| println('sure')
33| }
34| if Str3('2') in a_i {

Some files were not shown because too many files have changed in this diff Show More