From 6ada43df61f6726e3343aa4ff1cb9c6c07b45aa0 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sun, 12 Apr 2020 17:57:05 +0200 Subject: [PATCH] fmt: test automatic import insertion --- cmd/tools/vfmt.v | 2 +- vlib/v/fmt/fmt.v | 7 +++---- vlib/v/fmt/tests/missing_import_expected.vv | 5 +++++ vlib/v/fmt/tests/missing_import_input.vv | 3 +++ 4 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 vlib/v/fmt/tests/missing_import_expected.vv create mode 100644 vlib/v/fmt/tests/missing_import_input.vv diff --git a/cmd/tools/vfmt.v b/cmd/tools/vfmt.v index f304daa107..e2fada1a88 100644 --- a/cmd/tools/vfmt.v +++ b/cmd/tools/vfmt.v @@ -160,7 +160,7 @@ fn (foptions &FormatOptions) format_file(file string) { vfmt_output_path := os.join_path(os.temp_dir(), 'vfmt_' + file_name) os.write_file(vfmt_output_path, formatted_content ) if foptions.is_verbose { - eprintln('vfmt2 fmt.fmt worked and ${formatted_content.len} bytes were written to ${vfmt_output_path} .') + eprintln('fmt.fmt worked and ${formatted_content.len} bytes were written to ${vfmt_output_path} .') } eprintln('${FORMATTED_FILE_TOKEN}${vfmt_output_path}') } diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index fd565ddf50..5057899831 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -823,10 +823,9 @@ fn (f mut Fmt) call_expr(node ast.CallExpr) { alias: it.name } } - println(it.name + '!!') - for imp in f.file.imports { - println(imp.mod) - } + // for imp in f.file.imports { + // println(imp.mod) + // } } } else {} diff --git a/vlib/v/fmt/tests/missing_import_expected.vv b/vlib/v/fmt/tests/missing_import_expected.vv new file mode 100644 index 0000000000..c463392943 --- /dev/null +++ b/vlib/v/fmt/tests/missing_import_expected.vv @@ -0,0 +1,5 @@ +import time + +fn main() { + println(time.now()) +} diff --git a/vlib/v/fmt/tests/missing_import_input.vv b/vlib/v/fmt/tests/missing_import_input.vv new file mode 100644 index 0000000000..d173cb2181 --- /dev/null +++ b/vlib/v/fmt/tests/missing_import_input.vv @@ -0,0 +1,3 @@ +fn main() { + println(time.now()) +}