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

all: updateimport () and []array

This commit is contained in:
yuyi
2020-04-26 19:49:31 +08:00
committed by GitHub
parent 7b39ab6d06
commit 9f4d498ff1
59 changed files with 181 additions and 254 deletions

View File

@@ -10,11 +10,11 @@ fn main() {
min_str_len := 20
max_str_len := 40
println('Generating $sample_size strings between $min_str_len - $max_str_len chars long...')
mut bytepile := []byte
mut bytepile := []byte{}
for _ in 0 .. sample_size * max_str_len {
bytepile << byte(40 + rand.next(125 - 40))
}
mut str_lens := []int
mut str_lens := []int{}
for _ in 0 .. sample_size {
str_lens << min_str_len + rand.next(max_str_len - min_str_len)
}

View File

@@ -34,7 +34,7 @@ pub fn (mh mut TestMessageHandler) append_message(msg string) {
}
pub fn new_test_session(_vargs string) TestSession {
mut skip_files := []string
mut skip_files := []string{}
skip_files << '_non_existing_'
$if solaris {
skip_files << "examples/gg/gg2.v"
@@ -59,7 +59,7 @@ pub fn (ts mut TestSession) init() {
pub fn (ts mut TestSession) test() {
ts.init()
mut remaining_files := []string
mut remaining_files := []string{}
for dot_relative_file in ts.files {
relative_file := dot_relative_file.replace('./', '')
file := os.real_path(relative_file)
@@ -225,7 +225,7 @@ pub fn v_build_failing(zargs string, folder string) bool {
eprintln('v compiler args: "$vargs"')
mut session := new_test_session(vargs)
files := os.walk_ext(os.join_path(parent_dir, folder), '.v')
mut mains := []string
mut mains := []string{}
for f in files {
if !f.contains('modules') && !f.contains('preludes') {
$if windows {

View File

@@ -51,7 +51,7 @@ fn (c Context) compare_versions() {
// The first is the baseline, against which all the others will be compared.
// It is the fastest, since hello_world.v has only a single println in it,
mut perf_files := []string
mut perf_files := []string{}
perf_files << c.compare_v_performance('source_hello', [
'vprod @DEBUG@ -o source.c examples/hello_world.v',
'vprod -o source.c examples/hello_world.v',
@@ -147,7 +147,7 @@ fn (c Context) compare_v_performance(label string, commands []string) string {
timestamp_b,_ := vgit.line_to_timestamp_and_commit(scripting.run('cd $c.b/ ; git rev-list -n1 --timestamp HEAD'))
debug_option_a := if timestamp_a > 1570877641 { '-g ' } else { '-debug ' }
debug_option_b := if timestamp_b > 1570877641 { '-g ' } else { '-debug ' }
mut hyperfine_commands_arguments := []string
mut hyperfine_commands_arguments := []string{}
for cmd in commands {
println(cmd)
}

View File

@@ -20,7 +20,7 @@ fn (context Context) header() {
println('module ${context.module_name}')
println('')
allfiles := context.files.join(' ')
mut options := []string
mut options := []string{}
if context.prefix.len > 0 {
options << '-p ${context.prefix}'
}

View File

@@ -74,7 +74,7 @@ fn main() {
eprintln('vfmt env_vflags_and_os_args: ' + args.str())
eprintln('vfmt possible_files: ' + possible_files.str())
}
mut files := []string
mut files := []string{}
for file in possible_files {
if !file.ends_with('.v') && !file.ends_with('.vv') {
verror('v fmt can only be used on .v files.\nOffending file: "$file"')
@@ -90,7 +90,7 @@ fn main() {
vhelp.show_topic('fmt')
exit(0)
}
mut cli_args_no_files := []string
mut cli_args_no_files := []string{}
for a in os.args {
if a !in files {
cli_args_no_files << a
@@ -287,7 +287,7 @@ fn get_compile_name_of_potential_v_project(file string) string {
all_files_in_pfolder := os.ls(pfolder) or {
panic(err)
}
mut vfiles := []string
mut vfiles := []string{}
for f in all_files_in_pfolder {
vf := os.join_path(pfolder, f)
if f.starts_with('.') || !f.ends_with('.v') || os.is_dir(vf) {

View File

@@ -70,7 +70,7 @@ fn main(){
exit(0)
}
mut files := []string
mut files := []string{}
locations := fp.finalize() or { eprintln('Error: ' + err) exit(1) }
for xloc in locations {
loc := os.real_path(xloc)

View File

@@ -275,7 +275,7 @@ fn vpm_help() {
}
fn vcs_used_in_dir(dir string) ?[]string {
mut vcs := []string
mut vcs := []string{}
for repo_subfolder in supported_vcs_folders {
checked_folder := os.real_path(os.join_path(dir,repo_subfolder))
if os.is_dir(checked_folder) {
@@ -292,7 +292,7 @@ fn get_installed_modules() []string {
dirs := os.ls(settings.vmodules_path) or {
return []
}
mut modules := []string
mut modules := []string{}
for dir in dirs {
adir := os.join_path(settings.vmodules_path,dir)
if dir in excluded_dirs || !os.is_dir(adir) {
@@ -323,7 +323,7 @@ fn get_all_modules() []string {
}
s := r.text
mut read_len := 0
mut modules := []string
mut modules := []string{}
for read_len < s.len {
mut start_token := '<a href="/mod'
end_token := '</a>'
@@ -359,7 +359,7 @@ fn resolve_dependencies(name, module_path string, module_names []string) {
return
}
vmod := parse_vmod(data)
mut deps := []string
mut deps := []string{}
// filter out dependencies that were already specified by the user
for d in vmod.deps {
if d !in module_names {
@@ -440,7 +440,7 @@ fn verbose_println(s string) {
}
fn get_module_meta_info(name string) ?Mod {
mut errors := []string
mut errors := []string{}
for server_url in default_vpm_server_urls {
modurl := server_url + '/jsmod/$name'
verbose_println('Retrieving module metadata from: $modurl ...')

View File

@@ -54,7 +54,7 @@ fn v_test_formatting(vargs string) {
}
fn v_files() []string {
mut files_that_can_be_formatted := []string
mut files_that_can_be_formatted := []string{}
all_test_files := os.walk_ext('.', '.v')
for tfile in all_test_files {
if tfile in known_failing_exceptions {