diff --git a/vlib/v/fmt/tests/array_slices_expected.vv b/vlib/v/fmt/tests/array_slices_expected.vv index 243806de8a..c2b237c771 100644 --- a/vlib/v/fmt/tests/array_slices_expected.vv +++ b/vlib/v/fmt/tests/array_slices_expected.vv @@ -1,4 +1,3 @@ -[inline] fn fn_contains_index_expr() { arr := [1, 2, 3, 4, 5] a := 1 in arr[0..] diff --git a/vlib/v/fmt/tests/array_slices_input.vv b/vlib/v/fmt/tests/array_slices_input.vv index f773accf84..669cd6f5e1 100644 --- a/vlib/v/fmt/tests/array_slices_input.vv +++ b/vlib/v/fmt/tests/array_slices_input.vv @@ -1,6 +1,6 @@ -[inline] fn fn_contains_index_expr() { +fn fn_contains_index_expr() { arr := [1, 2, 3, 4, 5] a := 1 in arr[ 0.. ] b := 1 in arr[ ..2 ] diff --git a/vlib/v/fmt/tests/blocks_expected.vv b/vlib/v/fmt/tests/blocks_expected.vv new file mode 100644 index 0000000000..ac9d9e2608 --- /dev/null +++ b/vlib/v/fmt/tests/blocks_expected.vv @@ -0,0 +1,11 @@ +fn unsafe_fn() { + unsafe { + malloc(2) + } +} + +fn fn_with_defer() { + defer { + voidfn() + } +} diff --git a/vlib/v/fmt/tests/blocks_input.vv b/vlib/v/fmt/tests/blocks_input.vv new file mode 100644 index 0000000000..1761ca6ff8 --- /dev/null +++ b/vlib/v/fmt/tests/blocks_input.vv @@ -0,0 +1,7 @@ +fn unsafe_fn() { +unsafe { malloc(2) } +} + +fn fn_with_defer() { +defer { voidfn() } +} diff --git a/vlib/v/fmt/tests/cast_expected.vv b/vlib/v/fmt/tests/cast_expected.vv new file mode 100644 index 0000000000..7b69467057 --- /dev/null +++ b/vlib/v/fmt/tests/cast_expected.vv @@ -0,0 +1,7 @@ +fn test_as() { + a := sum_expr() as Bar +} + +fn test_cast() { + f := f32(0) +} diff --git a/vlib/v/fmt/tests/cast_input.vv b/vlib/v/fmt/tests/cast_input.vv new file mode 100644 index 0000000000..495579335f --- /dev/null +++ b/vlib/v/fmt/tests/cast_input.vv @@ -0,0 +1,7 @@ +fn test_as() { + a := sum_expr() as Bar +} + +fn test_cast() { + f := f32(0) +} diff --git a/vlib/v/fmt/tests/conditions_expected.vv b/vlib/v/fmt/tests/conditions_expected.vv new file mode 100644 index 0000000000..d9c69302f3 --- /dev/null +++ b/vlib/v/fmt/tests/conditions_expected.vv @@ -0,0 +1,12 @@ +fn fn_with_if_else() { + if true { + a = 10 + a++ + } else { + println('false') + } +} + +fn fn_with_if_else_oneline() { + x := if true { 1 } else { 2 } +} diff --git a/vlib/v/fmt/tests/conditions_input.vv b/vlib/v/fmt/tests/conditions_input.vv new file mode 100644 index 0000000000..552f28c6e6 --- /dev/null +++ b/vlib/v/fmt/tests/conditions_input.vv @@ -0,0 +1,10 @@ +fn fn_with_if_else() { + if true { + a = 10 + a++ + } else { println('false') } +} + +fn fn_with_if_else_oneline() { +x := if true { 1 } else { 2 } +} diff --git a/vlib/v/fmt/tests/consts_expected.vv b/vlib/v/fmt/tests/consts_expected.vv new file mode 100644 index 0000000000..f81be5f631 --- /dev/null +++ b/vlib/v/fmt/tests/consts_expected.vv @@ -0,0 +1,7 @@ +const ( + pi = 3.14 +) + +pub const ( + i_am_pub_const = true +) diff --git a/vlib/v/fmt/tests/consts_input.vv b/vlib/v/fmt/tests/consts_input.vv new file mode 100644 index 0000000000..2b7c5c874c --- /dev/null +++ b/vlib/v/fmt/tests/consts_input.vv @@ -0,0 +1,7 @@ +const ( +pi=3.14 +) + +pub const ( +i_am_pub_const=true +) diff --git a/vlib/v/fmt/tests/enums_expected.vv b/vlib/v/fmt/tests/enums_expected.vv new file mode 100644 index 0000000000..8c30ec2aeb --- /dev/null +++ b/vlib/v/fmt/tests/enums_expected.vv @@ -0,0 +1,9 @@ +pub enum PubEnum { + foo + bar +} + +enum PrivateEnum { + foo + bar +} diff --git a/vlib/v/fmt/tests/enums_input.vv b/vlib/v/fmt/tests/enums_input.vv new file mode 100644 index 0000000000..c7af1d693b --- /dev/null +++ b/vlib/v/fmt/tests/enums_input.vv @@ -0,0 +1,5 @@ +pub enum PubEnum{ + foo + bar +} +enum PrivateEnum { foo bar } diff --git a/vlib/v/fmt/tests/functions_expected.vv b/vlib/v/fmt/tests/functions_expected.vv new file mode 100644 index 0000000000..b22d8fc78f --- /dev/null +++ b/vlib/v/fmt/tests/functions_expected.vv @@ -0,0 +1,62 @@ +fn fn_variadic(arg int, args ...string) { + println('Do nothing') +} + +fn fn_with_assign_stmts() { + a, b := fn_with_multi_return() +} + +fn fn_with_multi_return() (int, string) { + return 0, 'test' +} + +fn voidfn() { + println('this is a function that does not return anything') +} + +fn fn_with_1_arg(arg int) int { + return 0 +} + +fn fn_with_2a_args(arg1, arg2 int) int { + return 0 +} + +fn fn_with_2_args_to_be_shorten(arg1, arg2 int) int { + return 0 +} + +fn fn_with_2b_args(arg1 string, arg2 int) int { + return 0 +} + +fn fn_with_3_args(arg1 string, arg2 int, arg3 User) int { + return 0 +} + +fn (this User) fn_with_receiver() { + println('') +} + +fn fn_with_optional() ?int { + if true { + return error('true') + } + return 30 +} + +fn (f Foo) fn_with_optional() ?int { + if true { + return error('true') + } + return 40 +} + +fn fn_with_ref_return() &Foo { + return &Foo{} +} + +[inline] +fn fn_with_flag() { + println('flag') +} diff --git a/vlib/v/fmt/tests/functions_input.vv b/vlib/v/fmt/tests/functions_input.vv new file mode 100644 index 0000000000..041a01f5ee --- /dev/null +++ b/vlib/v/fmt/tests/functions_input.vv @@ -0,0 +1,57 @@ +fn fn_variadic(arg int, args... string) { + println('Do nothing') +} + +fn fn_with_assign_stmts() { + a,b := fn_with_multi_return() +} + +fn fn_with_multi_return() (int,string) { + return 0,'test' +} + +fn voidfn(){ + println('this is a function that does not return anything') + } + +fn fn_with_1_arg(arg int) int { +return 0 +} + +fn fn_with_2a_args(arg1, arg2 int) int { +return 0 +} + +fn fn_with_2_args_to_be_shorten(arg1 int, arg2 int) int { +return 0 +} + +fn fn_with_2b_args(arg1 string, arg2 int) int { +return 0 +} + +fn fn_with_3_args(arg1 string, arg2 int, arg3 User) int { +return 0 +} + +fn (this User) fn_with_receiver() { +println('') +} + +fn fn_with_optional() ?int { + if true { return error('true') } + return 30 +} + +fn (f Foo) fn_with_optional() ?int { + if true { return error('true') } + return 40 +} + +fn fn_with_ref_return() &Foo { + return &Foo{} +} + +[inline] fn fn_with_flag() { +println('flag') +} diff --git a/vlib/v/fmt/tests/goto_expected.vv b/vlib/v/fmt/tests/goto_expected.vv new file mode 100644 index 0000000000..144a3ad8eb --- /dev/null +++ b/vlib/v/fmt/tests/goto_expected.vv @@ -0,0 +1,4 @@ +fn test_goto() { + goto label + label: +} diff --git a/vlib/v/fmt/tests/goto_input.vv b/vlib/v/fmt/tests/goto_input.vv new file mode 100644 index 0000000000..c0740dddd7 --- /dev/null +++ b/vlib/v/fmt/tests/goto_input.vv @@ -0,0 +1,4 @@ +fn test_goto() { + goto label +label: +} diff --git a/vlib/v/fmt/tests/maps_expected.vv b/vlib/v/fmt/tests/maps_expected.vv new file mode 100644 index 0000000000..701a6d8664 --- /dev/null +++ b/vlib/v/fmt/tests/maps_expected.vv @@ -0,0 +1,9 @@ +const ( + reserved_types = { + 'i8': true + 'i16': true + 'int': true + 'i64': true + 'i128': true + } +) diff --git a/vlib/v/fmt/tests/maps_input.vv b/vlib/v/fmt/tests/maps_input.vv new file mode 100644 index 0000000000..04d7a01df6 --- /dev/null +++ b/vlib/v/fmt/tests/maps_input.vv @@ -0,0 +1,9 @@ +const ( +reserved_types = { + 'i8': true + 'i16': true + 'int': true + 'i64': true + 'i128': true +} +) diff --git a/vlib/v/fmt/tests/match_expected.vv b/vlib/v/fmt/tests/match_expected.vv new file mode 100644 index 0000000000..b7b1ebe1bf --- /dev/null +++ b/vlib/v/fmt/tests/match_expected.vv @@ -0,0 +1,27 @@ +fn match_expr() { + a := 10 + match a { + 10 { + println('10') + } + 20 { + println('20') + } + else {} + } +} + +fn match_expr_assignment() { + a := 20 + b := match a { + 10 { + 10 + } + 5 { + 5 + } + else { + 2 + } + } +} diff --git a/vlib/v/fmt/tests/match_input.vv b/vlib/v/fmt/tests/match_input.vv new file mode 100644 index 0000000000..8221d0c958 --- /dev/null +++ b/vlib/v/fmt/tests/match_input.vv @@ -0,0 +1,21 @@ +fn match_expr() { + a := 10 + match a { + 10 { + println('10') + } + 20 { + println('20') + } + else {} + } +} + +fn match_expr_assignment() { + a := 20 + b := match a { + 10 { 10 } + 5 { 5 } + else { 2 } + } +} diff --git a/vlib/v/fmt/tests/or_expected.vv b/vlib/v/fmt/tests/or_expected.vv new file mode 100644 index 0000000000..72376d1265 --- /dev/null +++ b/vlib/v/fmt/tests/or_expected.vv @@ -0,0 +1,13 @@ +fn fn_with_or() int { + fn_with_optional() or { + return 10 + } + return 20 +} + +fn (f Foo) method_with_or() int { + f.fn_with_optional() or { + return 10 + } + return 20 +} diff --git a/vlib/v/fmt/tests/or_input.vv b/vlib/v/fmt/tests/or_input.vv new file mode 100644 index 0000000000..f67d40392c --- /dev/null +++ b/vlib/v/fmt/tests/or_input.vv @@ -0,0 +1,9 @@ +fn fn_with_or() int { + fn_with_optional() or { return 10 } + return 20 +} + +fn (f Foo) method_with_or() int { + f.fn_with_optional() or { return 10 } + return 20 +} diff --git a/vlib/v/fmt/tests/simple_expected.vv b/vlib/v/fmt/tests/simple_expected.vv deleted file mode 100644 index bda6776364..0000000000 --- a/vlib/v/fmt/tests/simple_expected.vv +++ /dev/null @@ -1,210 +0,0 @@ -fn main() { - mut a := 3 + 3 - a = 10 - a++ - -23 - goto lbl - b := 42 - println('hello') - abc() - lbl: - if true { - a = 10 - a++ - } else { - println('false') - } -} - -const ( - pi = 3.14 -) - -pub const ( - i_am_pub_const = true -) - -pub enum PubEnum { - foo - bar -} - -enum PrivateEnum { - foo - bar -} - -struct User { - name string - very_long_field bool -mut: - age int -} - -fn abc() int { - mut u := User{ - name: 'Bob' - } - u.age = 20 - nums := [1, 2, 3] - number := nums[0] - return 0 -} - -fn new_user() User { - return User{ - name: 'Serious Sam' - age: 19 - } -} - -fn voidfn() { - println('this is a function that does not return anything') -} - -fn fn_with_1_arg(arg int) int { - return 0 -} - -fn fn_with_2a_args(arg1, arg2 int) int { - return 0 -} - -fn fn_with_2_args_to_be_shorten(arg1, arg2 int) int { - return 0 -} - -fn fn_with_2b_args(arg1 string, arg2 int) int { - return 0 -} - -fn fn_with_3_args(arg1 string, arg2 int, arg3 User) int { - return 0 -} - -fn (this User) fn_with_receiver() { - x := if true { 1 } else { 2 } - println('') -} - -fn get_user() ?User { - return none -} - -fn get_user_ptr() &User { - return &User{} -} - -fn fn_with_defer() { - defer { - voidfn() - } -} - -struct Foo { - field1 int - field2 string -pub: - public_field1 int - public_field2 f64 -mut: - mut_field string -pub mut: - pub_mut_field string -} - -struct Bar { - val int -} - -type FooBar = Foo | Bar - -const ( - reserved_types = { - 'i8': true - 'i16': true - 'int': true - 'i64': true - 'i128': true - } -) - -fn fn_with_assign_stmts() { - a, b := fn_with_multi_return() -} - -fn fn_with_multi_return() (int, string) { - return 0, 'test' -} - -fn unsafe_fn() { - unsafe { - malloc(2) - } -} - -fn fn_with_or() int { - fn_with_optional() or { - return 10 - } - return 20 -} - -fn fn_with_optional() ?int { - if true { - return error('true') - } - return 30 -} - -fn (f Foo) method_with_or() int { - f.fn_with_optional() or { - return 10 - } - return 20 -} - -fn (f Foo) fn_with_optional() ?int { - if true { - return error('true') - } - return 40 -} - -fn fn_with_match_expr() { - a := 10 - b := match a { - 10 { - 10 - } - 5 { - 5 - } - else { - 2 - } - } - match b { - 10 { - println('10') - } - 20 { - println('20') - } - else {} - } -} - -fn fn_variadic(arg int, args ...string) { - println('Do nothing') -} - -fn test_as() { - a := sum_expr() as Bar -} - -fn sum_expr() FooBar { - return Bar{ - val: 5 - } -} diff --git a/vlib/v/fmt/tests/simple_input.vv b/vlib/v/fmt/tests/simple_input.vv deleted file mode 100644 index a7e0863d47..0000000000 --- a/vlib/v/fmt/tests/simple_input.vv +++ /dev/null @@ -1,207 +0,0 @@ -fn main() -{ - mut a:= 3 + 3 - a = 10 - a++ - -23 - goto lbl - b:= 42 - println( 'hello' ) - abc() - lbl: - if true { - a = 10 - a++ - } else { - println('false') - } -} - -const ( -pi=3.14 -) - -pub const ( -i_am_pub_const=true -) - -pub enum PubEnum{ - foo bar -} - -enum PrivateEnum{ - foo bar -} - -struct User { - name string - very_long_field bool - -mut: - age int -} - - -fn abc() int { - mut u := User{name:'Bob'} - u.age = 20 - - nums := [1,2,3] - number := nums[0] - return 0 -} - -fn new_user() -User -{ - return User{ - name: 'Serious Sam' - age: 19 - } -} - -fn voidfn(){ - println('this is a function that does not return anything') - } - -fn fn_with_1_arg(arg int) int { -return 0 -} - -fn fn_with_2a_args(arg1, arg2 int) int { -return 0 -} - -fn fn_with_2_args_to_be_shorten(arg1 int, arg2 int) int { -return 0 -} - -fn fn_with_2b_args(arg1 string, arg2 int) int { -return 0 -} - -fn fn_with_3_args(arg1 string, arg2 int, arg3 User) int { -return 0 -} - -fn (this User) fn_with_receiver() { - x := if true {1} else {2} -println('') -} - -fn get_user() ? User { - return none -} - -fn get_user_ptr() & User { - return &User{} -} - -fn fn_with_defer() { -defer { voidfn() -} -} - -struct Foo { - field1 int - field2 string - pub: - public_field1 int - public_field2 f64 - mut: - mut_field string - pub mut: - pub_mut_field string -} - -struct Bar { - val int -} - -type FooBar = Foo | Bar - -const ( -reserved_types = { - 'i8': true - 'i16': true - 'int': true - 'i64': true - 'i128': true -} -) - -fn fn_with_assign_stmts() { - a,b := fn_with_multi_return() -} - -fn fn_with_multi_return() (int,string) { - return 0,'test' -} - -fn unsafe_fn() { -unsafe { malloc(2) } -} - -fn fn_with_or() int { - fn_with_optional() or { - return 10 - } - return 20 -} - -fn fn_with_optional() ?int { - if true { - return error('true') - } - return 30 -} - -fn (f Foo) method_with_or() int { - f.fn_with_optional() or { - return 10 - } - return 20 -} - -fn (f Foo) fn_with_optional() ?int { - if true { - return error('true') - } - return 40 -} - -fn fn_with_match_expr() { - a := 10 - b := match a { - 10 { - 10 - } - 5 { - 5 - } - else { - 2 - } - } - match b { - 10 { - println('10') - } - 20 { - println('20') - } - else {} - } -} - -fn fn_variadic(arg int, args... string) { - println('Do nothing') -} - -fn test_as() { - a := sum_expr() as Bar -} - -fn sum_expr() FooBar { - return Bar{ val: 5 } -} diff --git a/vlib/v/fmt/tests/structs_expected.vv b/vlib/v/fmt/tests/structs_expected.vv new file mode 100644 index 0000000000..ae6d0b0e2c --- /dev/null +++ b/vlib/v/fmt/tests/structs_expected.vv @@ -0,0 +1,24 @@ +struct User { + name string + very_long_field bool + age int +} + +struct Foo { + field1 int + field2 string +pub: + public_field1 int + public_field2 f64 +mut: + mut_field string +pub mut: + pub_mut_field string +} + +fn new_user() User { + return User{ + name: 'Serious Sam' + age: 19 + } +} diff --git a/vlib/v/fmt/tests/structs_input.vv b/vlib/v/fmt/tests/structs_input.vv new file mode 100644 index 0000000000..154a80be86 --- /dev/null +++ b/vlib/v/fmt/tests/structs_input.vv @@ -0,0 +1,26 @@ +struct User { + name string + very_long_field bool + age int +} + +struct Foo { + field1 int + field2 string + pub: + public_field1 int + public_field2 f64 + mut: + mut_field string + pub mut: + pub_mut_field string +} + +fn new_user() +User +{ + return User{ + name: 'Serious Sam' + age: 19 + } +}