From a40df55bf5d6a074bd1f29e29715ff1482de7437 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Wed, 4 Dec 2024 02:47:13 +0200 Subject: [PATCH] vrepl: shrink .repl inputs, so repl_test.v runs faster --- vlib/v/slow_tests/repl/comptime_for.repl | 9 ++------- .../repl/conditional_blocks/for.repl | 4 +--- vlib/v/slow_tests/repl/enum.repl | 19 ++++--------------- .../repl/error_multi_line_fn_decl.repl | 17 ++++++----------- .../if_and_for_with_print_inside_them.repl | 8 ++------ vlib/v/slow_tests/repl/if_expr_oneline.repl | 3 +-- vlib/v/slow_tests/repl/interface.repl | 16 ++++------------ vlib/v/slow_tests/repl/print_and_fn_call.repl | 4 +--- vlib/v/slow_tests/repl/struct_def_later.repl | 12 +++--------- 9 files changed, 24 insertions(+), 68 deletions(-) diff --git a/vlib/v/slow_tests/repl/comptime_for.repl b/vlib/v/slow_tests/repl/comptime_for.repl index 9b971fea07..052406c2c8 100644 --- a/vlib/v/slow_tests/repl/comptime_for.repl +++ b/vlib/v/slow_tests/repl/comptime_for.repl @@ -1,10 +1,5 @@ -struct Person { - name string - age int -} -$for field in Person.fields { - println(field.name) -} +struct Person { name string age int } +$for field in Person.fields { println(field.name) } ===output=== name age diff --git a/vlib/v/slow_tests/repl/conditional_blocks/for.repl b/vlib/v/slow_tests/repl/conditional_blocks/for.repl index 2f3f50cba6..bf532698c5 100644 --- a/vlib/v/slow_tests/repl/conditional_blocks/for.repl +++ b/vlib/v/slow_tests/repl/conditional_blocks/for.repl @@ -1,6 +1,4 @@ -for i := 0; i < 4; i++ { - println(i) -} +for i := 0; i < 4; i++ { println(i) } ===output=== 0 1 diff --git a/vlib/v/slow_tests/repl/enum.repl b/vlib/v/slow_tests/repl/enum.repl index b419f1a43e..d328bd20a0 100644 --- a/vlib/v/slow_tests/repl/enum.repl +++ b/vlib/v/slow_tests/repl/enum.repl @@ -1,18 +1,7 @@ -mut age := 20 -enum Info { -young -old -} -fn get_info(age int) Info { -if age < 25 { -return .young -} else { -return .old -} -} -get_info(age) -age = 45 -get_info(age) +enum Info { young old } +fn get_info(age int) Info { if age < 25 { return .young } else { return .old } } +mut age := 20; println(get_info(age)); age = 45; println(get_info(age)) ===output=== young old + diff --git a/vlib/v/slow_tests/repl/error_multi_line_fn_decl.repl b/vlib/v/slow_tests/repl/error_multi_line_fn_decl.repl index 624b90a488..69baa38f1e 100644 --- a/vlib/v/slow_tests/repl/error_multi_line_fn_decl.repl +++ b/vlib/v/slow_tests/repl/error_multi_line_fn_decl.repl @@ -1,20 +1,15 @@ +fn test() { aaa } +fn print_info(n int) { println('${n}') } mut a := 22 -fn test() { -aaa -} -fn print_info(n int) { -println('${n}') -} print_info(a) a = 11 print_info(a) ===output=== error: `aaa` evaluated but not used + 6 | 7 | fn test() { - 8 | - 9 | aaa - | ~~~ - 10 | - 11 | } + 8 | aaa + | ~~~ + 9 | } 22 11 diff --git a/vlib/v/slow_tests/repl/if_and_for_with_print_inside_them.repl b/vlib/v/slow_tests/repl/if_and_for_with_print_inside_them.repl index 454571c64b..f1fcd7d85f 100644 --- a/vlib/v/slow_tests/repl/if_and_for_with_print_inside_them.repl +++ b/vlib/v/slow_tests/repl/if_and_for_with_print_inside_them.repl @@ -1,11 +1,7 @@ mut numbers := [1,2,3,4,5] -if 1 in numbers { -println('yes') -} +if 1 in numbers { println('yes') } println('hi') -for number in numbers { -println(number) -} +for number in numbers { println(number) } println(numbers) ===output=== yes diff --git a/vlib/v/slow_tests/repl/if_expr_oneline.repl b/vlib/v/slow_tests/repl/if_expr_oneline.repl index f3cca6329c..d4726211f7 100644 --- a/vlib/v/slow_tests/repl/if_expr_oneline.repl +++ b/vlib/v/slow_tests/repl/if_expr_oneline.repl @@ -1,4 +1,3 @@ -a := 22 -if a > 10 { println('good') } else { println('bad') } +a := 22; if a > 10 { println('good') } else { println('bad') } ===output=== good diff --git a/vlib/v/slow_tests/repl/interface.repl b/vlib/v/slow_tests/repl/interface.repl index 74f0e644e9..4441b9f068 100644 --- a/vlib/v/slow_tests/repl/interface.repl +++ b/vlib/v/slow_tests/repl/interface.repl @@ -1,16 +1,8 @@ name := 'hello' -interface Foo { -get_name() string -} -struct Bar { -name string -} -fn (bar Bar) get_name() string { -return bar.name -} -fn get_name(foo Foo) string { -return foo.get_name() -} +interface Foo { get_name() string } +struct Bar { name string } +fn (bar Bar) get_name() string { return bar.name } +fn get_name(foo Foo) string { return foo.get_name() } bar := Bar{name} get_name(bar) ===output=== diff --git a/vlib/v/slow_tests/repl/print_and_fn_call.repl b/vlib/v/slow_tests/repl/print_and_fn_call.repl index 5e02ef33c7..a61ecce6b1 100644 --- a/vlib/v/slow_tests/repl/print_and_fn_call.repl +++ b/vlib/v/slow_tests/repl/print_and_fn_call.repl @@ -1,8 +1,6 @@ println('hello') fn abc(x int) { println(x) } -abc(123) -abc(456) -println('hello') +abc(123);abc(456);println('hello') ===output=== hello 123 diff --git a/vlib/v/slow_tests/repl/struct_def_later.repl b/vlib/v/slow_tests/repl/struct_def_later.repl index 76e225c67c..5ff8ef570b 100644 --- a/vlib/v/slow_tests/repl/struct_def_later.repl +++ b/vlib/v/slow_tests/repl/struct_def_later.repl @@ -1,19 +1,13 @@ mut name := 'foo1' -pub struct Info1 { -name string -} +pub struct Info1 { name string } info1 := Info1{name} info1 name = 'foo2' -struct Info2 { -name string -} +struct Info2 { name string } info2 := Info2{name} info2 name = 'foo3' -struct Info3 { -name string -} +struct Info3 { name string } info3 := Info3{name} info3 ===output===