fmt: fix unnecessary line break in array init (fix #11448) (#11562)

pull/11568/head
yuyi 2021-09-21 21:20:09 +08:00 committed by GitHub
parent d6fa6a459c
commit 108a01d65f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
47 changed files with 532 additions and 518 deletions

View File

@ -472,8 +472,7 @@ pub fn building_any_v_binaries_failed() bool {
mut failed := false
v_build_commands := ['$vexe -o v_g -g cmd/v', '$vexe -o v_prod_g -prod -g cmd/v',
'$vexe -o v_cg -cg cmd/v', '$vexe -o v_prod_cg -prod -cg cmd/v',
'$vexe -o v_prod -prod cmd/v',
]
'$vexe -o v_prod -prod cmd/v']
mut bmark := benchmark.new_benchmark()
for cmd in v_build_commands {
bmark.step()

View File

@ -56,15 +56,18 @@ fn (c Context) compare_versions() {
'v @DEBUG@ -o source.c examples/hello_world.v',
'v -o source.c examples/hello_world.v',
])
perf_files << c.compare_v_performance('source_v', ['vprod @DEBUG@ -o source.c @COMPILER@',
'vprod -o source.c @COMPILER@', 'v @DEBUG@ -o source.c @COMPILER@',
perf_files << c.compare_v_performance('source_v', [
'vprod @DEBUG@ -o source.c @COMPILER@',
'vprod -o source.c @COMPILER@',
'v @DEBUG@ -o source.c @COMPILER@',
'v -o source.c @COMPILER@',
])
perf_files << c.compare_v_performance('binary_hello', [
'vprod -o hello examples/hello_world.v',
'v -o hello examples/hello_world.v',
])
perf_files << c.compare_v_performance('binary_v', ['vprod -o binary @COMPILER@',
perf_files << c.compare_v_performance('binary_v', [
'vprod -o binary @COMPILER@',
'v -o binary @COMPILER@',
])
println('All performance files:')
@ -107,8 +110,7 @@ fn (c &Context) prepare_v(cdir string, commit string) {
scripting.show_sizes_of_files(['$cdir/cv', '$cdir/cv_stripped', '$cdir/cv_stripped_upxed'])
scripting.show_sizes_of_files(['$cdir/v', '$cdir/v_stripped', '$cdir/v_stripped_upxed'])
scripting.show_sizes_of_files(['$cdir/vprod', '$cdir/vprod_stripped',
'$cdir/vprod_stripped_upxed',
])
'$cdir/vprod_stripped_upxed'])
vversion := scripting.run('$cdir/v -version')
vcommit := scripting.run('git rev-parse --short --verify HEAD')
println('V version is: $vversion , local source commit: $vcommit')

View File

@ -149,8 +149,7 @@ fn color_highlight(code string, tb &ast.Table) string {
.string {
use_double_quote := tok.lit.contains("'") && !tok.lit.contains('"')
unescaped_val := tok.lit.replace('\\\\', '\x01').replace_each(["\\'", "'", '\\"',
'"',
])
'"'])
if use_double_quote {
s := unescaped_val.replace_each(['\x01', '\\\\', '"', '\\"'])
lit = term.yellow('"$s"')

View File

@ -289,11 +289,9 @@ fn (mut vd VDoc) generate_docs_from_file() {
}
}
}
dirs := if cfg.is_multi {
get_modules_list(cfg.input_path, []string{})
} else {
[cfg.input_path]
}
dirs := if cfg.is_multi { get_modules_list(cfg.input_path, []string{}) } else { [
cfg.input_path,
] }
for dirpath in dirs {
vd.vprintln('Generating $out.typ docs for "$dirpath"')
mut dcs := doc.generate(dirpath, cfg.pub_only, true, cfg.platform, cfg.symbol_name) or {

View File

@ -26,8 +26,7 @@ fn main() {
fn frame(mut app App) {
app.gg.begin()
app.gg.draw_convex_poly([f32(100.0), 100.0, 200.0, 100.0, 300.0, 200.0, 200.0, 300.0, 100.0,
300.0,
], gx.blue)
300.0], gx.blue)
app.gg.draw_empty_poly([f32(50.0), 50.0, 70.0, 60.0, 90.0, 80.0, 70.0, 110.0], gx.black)
app.gg.draw_triangle(450, 142, 530, 280, 370, 280, gx.red)
app.gg.end()

View File

@ -166,135 +166,159 @@ fn (sp Sphere) intersect(r Ray) f64 {
const (
cen = Vec{50, 40.8, -860} // used by scene 1
spheres = [
[/* scene 0 cornnel box */ Sphere{
rad: 1e+5
p: Vec{1e+5 + 1, 40.8, 81.6}
e: Vec{}
c: Vec{.75, .25, .25}
refl: .diff
}, /* Left */ Sphere{
rad: 1e+5
p: Vec{-1e+5 + 99, 40.8, 81.6}
e: Vec{}
c: Vec{.25, .25, .75}
refl: .diff
}, /* Rght */ Sphere{
rad: 1e+5
p: Vec{50, 40.8, 1e+5}
e: Vec{}
c: Vec{.75, .75, .75}
refl: .diff
}, /* Back */ Sphere{
rad: 1e+5
p: Vec{50, 40.8, -1e+5 + 170}
e: Vec{}
c: Vec{}
refl: .diff
}, /* Frnt */ Sphere{
rad: 1e+5
p: Vec{50, 1e+5, 81.6}
e: Vec{}
c: Vec{.75, .75, .75}
refl: .diff
}, /* Botm */ Sphere{
rad: 1e+5
p: Vec{50, -1e+5 + 81.6, 81.6}
e: Vec{}
c: Vec{.75, .75, .75}
refl: .diff
}, /* Top */ Sphere{
rad: 16.5
p: Vec{27, 16.5, 47}
e: Vec{}
c: Vec{1, 1, 1}.mult_s(.999)
refl: .spec
}, /* Mirr */ Sphere{
rad: 16.5
p: Vec{73, 16.5, 78}
e: Vec{}
c: Vec{1, 1, 1}.mult_s(.999)
refl: .refr
}, /* Glas */ Sphere{
rad: 600
p: Vec{50, 681.6 - .27, 81.6}
e: Vec{12, 12, 12}
c: Vec{}
refl: .diff
} /* Lite */],
[/* scene 1 sunset */ Sphere{
rad: 1600
p: Vec{1.0, 0.0, 2.0}.mult_s(3000)
e: Vec{1.0, .9, .8}.mult_s(1.2e+1 * 1.56 * 2)
c: Vec{}
refl: .diff
}, /* sun */ Sphere{
rad: 1560
p: Vec{1, 0, 2}.mult_s(3500)
e: Vec{1.0, .5, .05}.mult_s(4.8e+1 * 1.56 * 2)
c: Vec{}
refl: .diff
}, /* horizon sun2 */ Sphere{
rad: 10000
p: cen + Vec{0, 0, -200}
e: Vec{0.00063842, 0.02001478, 0.28923243}.mult_s(6e-2 * 8)
c: Vec{.7, .7, 1}.mult_s(.25)
refl: .diff
}, /* sky */ Sphere{
rad: 100000
p: Vec{50, -100000, 0}
e: Vec{}
c: Vec{.3, .3, .3}
refl: .diff
}, /* grnd */ Sphere{
rad: 110000
p: Vec{50, -110048.5, 0}
e: Vec{.9, .5, .05}.mult_s(4)
c: Vec{}
refl: .diff
}, /* horizon brightener */ Sphere{
rad: 4e+4
p: Vec{50, -4e+4 - 30, -3000}
e: Vec{}
c: Vec{.2, .2, .2}
refl: .diff
}, /* mountains */ Sphere{
rad: 26.5
p: Vec{22, 26.5, 42}
e: Vec{}
c: Vec{1, 1, 1}.mult_s(.596)
refl: .spec
}, /* white Mirr */ Sphere{
rad: 13
p: Vec{75, 13, 82}
e: Vec{}
c: Vec{.96, .96, .96}.mult_s(.96)
refl: .refr
}, /* Glas */ Sphere{
rad: 22
p: Vec{87, 22, 24}
e: Vec{}
c: Vec{.6, .6, .6}.mult_s(.696)
refl: .refr
} /* Glas2 */],
[/* scene 3 Psychedelic */ Sphere{
rad: 150
p: Vec{50 + 75, 28, 62}
e: Vec{1, 1, 1}.mult_s(0e-3)
c: Vec{1, .9, .8}.mult_s(.93)
refl: .refr
}, Sphere{
rad: 28
p: Vec{50 + 5, -28, 62}
e: Vec{1, 1, 1}.mult_s(1e+1)
c: Vec{1, 1, 1}.mult_s(0)
refl: .diff
}, Sphere{
rad: 300
p: Vec{50, 28, 62}
e: Vec{1, 1, 1}.mult_s(0e-3)
c: Vec{1, 1, 1}.mult_s(.93)
refl: .spec
}],
[// scene 0 cornnel box
Sphere{
rad: 1e+5
p: Vec{1e+5 + 1, 40.8, 81.6}
e: Vec{}
c: Vec{.75, .25, .25}
refl: .diff
}, /* Left */
Sphere{
rad: 1e+5
p: Vec{-1e+5 + 99, 40.8, 81.6}
e: Vec{}
c: Vec{.25, .25, .75}
refl: .diff
}, /* Rght */
Sphere{
rad: 1e+5
p: Vec{50, 40.8, 1e+5}
e: Vec{}
c: Vec{.75, .75, .75}
refl: .diff
}, /* Back */
Sphere{
rad: 1e+5
p: Vec{50, 40.8, -1e+5 + 170}
e: Vec{}
c: Vec{}
refl: .diff
}, /* Frnt */
Sphere{
rad: 1e+5
p: Vec{50, 1e+5, 81.6}
e: Vec{}
c: Vec{.75, .75, .75}
refl: .diff
}, /* Botm */
Sphere{
rad: 1e+5
p: Vec{50, -1e+5 + 81.6, 81.6}
e: Vec{}
c: Vec{.75, .75, .75}
refl: .diff
}, /* Top */
Sphere{
rad: 16.5
p: Vec{27, 16.5, 47}
e: Vec{}
c: Vec{1, 1, 1}.mult_s(.999)
refl: .spec
}, /* Mirr */
Sphere{
rad: 16.5
p: Vec{73, 16.5, 78}
e: Vec{}
c: Vec{1, 1, 1}.mult_s(.999)
refl: .refr
}, /* Glas */
Sphere{
rad: 600
p: Vec{50, 681.6 - .27, 81.6}
e: Vec{12, 12, 12}
c: Vec{}
refl: .diff
} /* Lite */,
],
[// scene 1 sunset
Sphere{
rad: 1600
p: Vec{1.0, 0.0, 2.0}.mult_s(3000)
e: Vec{1.0, .9, .8}.mult_s(1.2e+1 * 1.56 * 2)
c: Vec{}
refl: .diff
}, /* sun */
Sphere{
rad: 1560
p: Vec{1, 0, 2}.mult_s(3500)
e: Vec{1.0, .5, .05}.mult_s(4.8e+1 * 1.56 * 2)
c: Vec{}
refl: .diff
}, /* horizon sun2 */
Sphere{
rad: 10000
p: cen + Vec{0, 0, -200}
e: Vec{0.00063842, 0.02001478, 0.28923243}.mult_s(6e-2 * 8)
c: Vec{.7, .7, 1}.mult_s(.25)
refl: .diff
}, /* sky */
Sphere{
rad: 100000
p: Vec{50, -100000, 0}
e: Vec{}
c: Vec{.3, .3, .3}
refl: .diff
}, /* grnd */
Sphere{
rad: 110000
p: Vec{50, -110048.5, 0}
e: Vec{.9, .5, .05}.mult_s(4)
c: Vec{}
refl: .diff
}, /* horizon brightener */
Sphere{
rad: 4e+4
p: Vec{50, -4e+4 - 30, -3000}
e: Vec{}
c: Vec{.2, .2, .2}
refl: .diff
}, /* mountains */
Sphere{
rad: 26.5
p: Vec{22, 26.5, 42}
e: Vec{}
c: Vec{1, 1, 1}.mult_s(.596)
refl: .spec
}, /* white Mirr */
Sphere{
rad: 13
p: Vec{75, 13, 82}
e: Vec{}
c: Vec{.96, .96, .96}.mult_s(.96)
refl: .refr
}, /* Glas */
Sphere{
rad: 22
p: Vec{87, 22, 24}
e: Vec{}
c: Vec{.6, .6, .6}.mult_s(.696)
refl: .refr
} /* Glas2 */,
],
[// scene 3 Psychedelic
Sphere{
rad: 150
p: Vec{50 + 75, 28, 62}
e: Vec{1, 1, 1}.mult_s(0e-3)
c: Vec{1, .9, .8}.mult_s(.93)
refl: .refr
},
Sphere{
rad: 28
p: Vec{50 + 5, -28, 62}
e: Vec{1, 1, 1}.mult_s(1e+1)
c: Vec{1, 1, 1}.mult_s(0)
refl: .diff
},
Sphere{
rad: 300
p: Vec{50, 28, 62}
e: Vec{1, 1, 1}.mult_s(0e-3)
c: Vec{1, 1, 1}.mult_s(.93)
refl: .spec
},
],
] // end of scene array
)

View File

@ -23,150 +23,164 @@ pub enum SiteCat {
}
fn data_get() []SiteConfig {
data := [SiteConfig{
name: 'www_threefold_io'
url: 'https://github.com/threefoldfoundation/www_threefold_io'
branch: 'default'
pull: false
cat: .web
alias: 'tf'
path_code: '/Users/despiegk/codewww/github/threefoldfoundation/www_threefold_io'
domains: ['www.threefold.io', 'www.threefold.me']
descr: 'is our entry point for everyone, redirect to the detailed websites underneith.'
}, SiteConfig{
name: 'www_threefold_cloud'
url: 'https://github.com/threefoldfoundation/www_threefold_cloud'
branch: 'default'
pull: false
cat: .web
alias: 'cloud'
path_code: '/Users/despiegk/codewww/github/threefoldfoundation/www_threefold_cloud'
domains: ['cloud.threefold.io', 'cloud.threefold.me']
descr: 'for people looking to deploy solutions on top of a cloud, alternative to e.g. digital ocean'
}, SiteConfig{
name: 'www_threefold_farming'
url: 'https://github.com/threefoldfoundation/www_threefold_farming'
branch: 'default'
pull: false
cat: .web
alias: 'farming'
path_code: '/Users/despiegk/codewww/github/threefoldfoundation/www_threefold_farming'
domains: ['farming.threefold.io', 'farming.threefold.me']
descr: 'crypto & minining enthusiasts, be the internet, know about farming & tokens.'
}, SiteConfig{
name: 'www_threefold_twin'
url: 'https://github.com/threefoldfoundation/www_threefold_twin'
branch: 'default'
pull: false
cat: .web
alias: 'twin'
path_code: '/Users/despiegk/codewww/github/threefoldfoundation/www_threefold_twin'
domains: ['twin.threefold.io', 'twin.threefold.me']
descr: 'you digital life'
}, SiteConfig{
name: 'www_threefold_marketplace'
url: 'https://github.com/threefoldfoundation/www_threefold_marketplace'
branch: 'default'
pull: false
cat: .web
alias: 'marketplace'
path_code: '/Users/despiegk/codewww/github/threefoldfoundation/www_threefold_marketplace'
domains: ['now.threefold.io', 'marketplace.threefold.io', 'now.threefold.me',
'marketplace.threefold.me',
]
descr: 'apps for community builders, runs on top of evdc'
}, SiteConfig{
name: 'www_conscious_internet'
url: 'https://github.com/threefoldfoundation/www_conscious_internet'
branch: 'default'
pull: false
cat: .web
alias: 'conscious_internet'
path_code: '/Users/despiegk/codewww/github/threefoldfoundation/www_conscious_internet'
domains: ['www.consciousinternet.org', 'eco.threefold.io', 'community.threefold.io',
'eco.threefold.me', 'community.threefold.me']
descr: 'community around threefold, partners, friends, ...'
}, SiteConfig{
name: 'www_threefold_tech'
url: 'https://github.com/threefoldtech/www_threefold_tech'
branch: 'default'
pull: false
cat: .web
alias: 'tech'
path_code: '/Users/despiegk/codewww/github/threefoldtech/www_threefold_tech'
domains: ['www.threefold.tech']
descr: 'cyberpandemic, use the tech to build your own solutions with, certification for TFGrid'
}, SiteConfig{
name: 'www_examplesite'
url: 'https://github.com/threefoldfoundation/www_examplesite'
branch: 'default'
pull: false
cat: .web
alias: 'example'
path_code: '/Users/despiegk/codewww/github/threefoldfoundation/www_examplesite'
domains: ['example.threefold.io']
descr: ''
}, SiteConfig{
name: 'info_threefold'
url: 'https://github.com/threefoldfoundation/info_foundation_archive'
branch: 'default'
pull: false
cat: .wiki
alias: 'threefold'
path_code: '/Users/despiegk/codewww/github/threefoldfoundation/info_foundation_archive'
domains: ['info.threefold.io']
descr: 'wiki for foundation, collaborate, what if farmings, tokens'
}, SiteConfig{
name: 'info_sdk'
url: 'https://github.com/threefoldfoundation/info_sdk'
branch: 'default'
pull: false
cat: .wiki
alias: 'sdk'
path_code: '/Users/despiegk/codewww/github/threefoldfoundation/info_sdk'
domains: ['sdk.threefold.io', 'sdk_info.threefold.io']
descr: 'for IAC, devops, how to do Infrastruture As Code, 3bot, Ansible, tfgrid-sdk, ...'
}, SiteConfig{
name: 'info_legal'
url: 'https://github.com/threefoldfoundation/info_legal'
branch: 'default'
pull: false
cat: .wiki
alias: 'legal'
path_code: '/Users/despiegk/codewww/github/threefoldfoundation/info_legal'
domains: ['legal.threefold.io', 'legal_info.threefold.io']
descr: ''
}, SiteConfig{
name: 'info_cloud'
url: 'https://github.com/threefoldfoundation/info_cloud'
branch: 'default'
pull: false
cat: .wiki
alias: 'cloud'
path_code: '/Users/despiegk/codewww/github/threefoldfoundation/info_cloud'
domains: ['cloud_info.threefold.io']
descr: 'how to use the cloud for deploying apps: evdc, kubernetes, planetary fs, ... + marketplace solutions '
}, SiteConfig{
name: 'info_tftech'
url: 'https://github.com/threefoldtech/info_tftech'
branch: 'default'
pull: false
cat: .wiki
alias: 'tftech'
path_code: '/Users/despiegk/codewww/github/threefoldtech/info_tftech'
domains: ['info.threefold.tech']
descr: ''
}, SiteConfig{
name: 'info_digitaltwin'
url: 'https://github.com/threefoldfoundation/info_digitaltwin.git'
branch: 'default'
pull: false
cat: .wiki
alias: 'twin'
path_code: '/Users/despiegk/codewww/github/threefoldfoundation/info_digitaltwin'
domains: ['twin_info.threefold.io']
descr: ''
}]
data := [
SiteConfig{
name: 'www_threefold_io'
url: 'https://github.com/threefoldfoundation/www_threefold_io'
branch: 'default'
pull: false
cat: .web
alias: 'tf'
path_code: '/Users/despiegk/codewww/github/threefoldfoundation/www_threefold_io'
domains: ['www.threefold.io', 'www.threefold.me']
descr: 'is our entry point for everyone, redirect to the detailed websites underneith.'
},
SiteConfig{
name: 'www_threefold_cloud'
url: 'https://github.com/threefoldfoundation/www_threefold_cloud'
branch: 'default'
pull: false
cat: .web
alias: 'cloud'
path_code: '/Users/despiegk/codewww/github/threefoldfoundation/www_threefold_cloud'
domains: ['cloud.threefold.io', 'cloud.threefold.me']
descr: 'for people looking to deploy solutions on top of a cloud, alternative to e.g. digital ocean'
},
SiteConfig{
name: 'www_threefold_farming'
url: 'https://github.com/threefoldfoundation/www_threefold_farming'
branch: 'default'
pull: false
cat: .web
alias: 'farming'
path_code: '/Users/despiegk/codewww/github/threefoldfoundation/www_threefold_farming'
domains: ['farming.threefold.io', 'farming.threefold.me']
descr: 'crypto & minining enthusiasts, be the internet, know about farming & tokens.'
},
SiteConfig{
name: 'www_threefold_twin'
url: 'https://github.com/threefoldfoundation/www_threefold_twin'
branch: 'default'
pull: false
cat: .web
alias: 'twin'
path_code: '/Users/despiegk/codewww/github/threefoldfoundation/www_threefold_twin'
domains: ['twin.threefold.io', 'twin.threefold.me']
descr: 'you digital life'
},
SiteConfig{
name: 'www_threefold_marketplace'
url: 'https://github.com/threefoldfoundation/www_threefold_marketplace'
branch: 'default'
pull: false
cat: .web
alias: 'marketplace'
path_code: '/Users/despiegk/codewww/github/threefoldfoundation/www_threefold_marketplace'
domains: ['now.threefold.io', 'marketplace.threefold.io', 'now.threefold.me',
'marketplace.threefold.me']
descr: 'apps for community builders, runs on top of evdc'
},
SiteConfig{
name: 'www_conscious_internet'
url: 'https://github.com/threefoldfoundation/www_conscious_internet'
branch: 'default'
pull: false
cat: .web
alias: 'conscious_internet'
path_code: '/Users/despiegk/codewww/github/threefoldfoundation/www_conscious_internet'
domains: ['www.consciousinternet.org', 'eco.threefold.io', 'community.threefold.io',
'eco.threefold.me', 'community.threefold.me']
descr: 'community around threefold, partners, friends, ...'
},
SiteConfig{
name: 'www_threefold_tech'
url: 'https://github.com/threefoldtech/www_threefold_tech'
branch: 'default'
pull: false
cat: .web
alias: 'tech'
path_code: '/Users/despiegk/codewww/github/threefoldtech/www_threefold_tech'
domains: ['www.threefold.tech']
descr: 'cyberpandemic, use the tech to build your own solutions with, certification for TFGrid'
},
SiteConfig{
name: 'www_examplesite'
url: 'https://github.com/threefoldfoundation/www_examplesite'
branch: 'default'
pull: false
cat: .web
alias: 'example'
path_code: '/Users/despiegk/codewww/github/threefoldfoundation/www_examplesite'
domains: ['example.threefold.io']
descr: ''
},
SiteConfig{
name: 'info_threefold'
url: 'https://github.com/threefoldfoundation/info_foundation_archive'
branch: 'default'
pull: false
cat: .wiki
alias: 'threefold'
path_code: '/Users/despiegk/codewww/github/threefoldfoundation/info_foundation_archive'
domains: ['info.threefold.io']
descr: 'wiki for foundation, collaborate, what if farmings, tokens'
},
SiteConfig{
name: 'info_sdk'
url: 'https://github.com/threefoldfoundation/info_sdk'
branch: 'default'
pull: false
cat: .wiki
alias: 'sdk'
path_code: '/Users/despiegk/codewww/github/threefoldfoundation/info_sdk'
domains: ['sdk.threefold.io', 'sdk_info.threefold.io']
descr: 'for IAC, devops, how to do Infrastruture As Code, 3bot, Ansible, tfgrid-sdk, ...'
},
SiteConfig{
name: 'info_legal'
url: 'https://github.com/threefoldfoundation/info_legal'
branch: 'default'
pull: false
cat: .wiki
alias: 'legal'
path_code: '/Users/despiegk/codewww/github/threefoldfoundation/info_legal'
domains: ['legal.threefold.io', 'legal_info.threefold.io']
descr: ''
},
SiteConfig{
name: 'info_cloud'
url: 'https://github.com/threefoldfoundation/info_cloud'
branch: 'default'
pull: false
cat: .wiki
alias: 'cloud'
path_code: '/Users/despiegk/codewww/github/threefoldfoundation/info_cloud'
domains: ['cloud_info.threefold.io']
descr: 'how to use the cloud for deploying apps: evdc, kubernetes, planetary fs, ... + marketplace solutions '
},
SiteConfig{
name: 'info_tftech'
url: 'https://github.com/threefoldtech/info_tftech'
branch: 'default'
pull: false
cat: .wiki
alias: 'tftech'
path_code: '/Users/despiegk/codewww/github/threefoldtech/info_tftech'
domains: ['info.threefold.tech']
descr: ''
},
SiteConfig{
name: 'info_digitaltwin'
url: 'https://github.com/threefoldfoundation/info_digitaltwin.git'
branch: 'default'
pull: false
cat: .wiki
alias: 'twin'
path_code: '/Users/despiegk/codewww/github/threefoldfoundation/info_digitaltwin'
domains: ['twin_info.threefold.io']
descr: ''
},
]
return data
}

View File

@ -119,8 +119,7 @@ fn test_window() {
x := [1, 2, 3, 4, 5, 6]
assert window<int>(x, size: 3) == [[1, 2, 3], [2, 3, 4], [3, 4, 5],
[4, 5, 6],
]
[4, 5, 6]]
assert window<int>(x, size: 3, step: 2) == [[1, 2, 3], [3, 4, 5]]
assert window<int>([]int{}, size: 2) == [][]int{}
}

View File

@ -428,11 +428,9 @@ fn test_multi_array_clone() {
a3_1[0][0][1] = 0
a3_2[0][1][0] = 0
assert a3_1 == [[[1, 0], [2, 2], [3, 3]], [[4, 4], [5, 5],
[6, 6],
]]
[6, 6]]]
assert a3_2 == [[[1, 1], [0, 2], [3, 3]], [[4, 4], [5, 5],
[6, 6],
]]
[6, 6]]]
// 3d array_string
mut b3_1 := [[['1', '1'], ['2', '2'], ['3', '3']], [['4', '4'],
['5', '5'], ['6', '6']]]
@ -1339,19 +1337,22 @@ fn test_struct_array_of_multi_type_in() {
'aaa': '111'
}
}
people := [Person{
name: 'ivan'
nums: [1, 2, 3]
kv: {
'aaa': '111'
}
}, Person{
name: 'bob'
nums: [2]
kv: {
'bbb': '222'
}
}]
people := [
Person{
name: 'ivan'
nums: [1, 2, 3]
kv: {
'aaa': '111'
}
},
Person{
name: 'bob'
nums: [2]
kv: {
'bbb': '222'
}
},
]
println(ivan in people)
assert ivan in people
}
@ -1364,19 +1365,22 @@ fn test_struct_array_of_multi_type_index() {
'aaa': '111'
}
}
people := [Person{
name: 'ivan'
nums: [1, 2, 3]
kv: {
'aaa': '111'
}
}, Person{
name: 'bob'
nums: [2]
kv: {
'bbb': '222'
}
}]
people := [
Person{
name: 'ivan'
nums: [1, 2, 3]
kv: {
'aaa': '111'
}
},
Person{
name: 'bob'
nums: [2]
kv: {
'bbb': '222'
}
},
]
println(people.index(ivan))
assert people.index(ivan) == 0
}

View File

@ -28,8 +28,7 @@ fn test_strip_margins_white_space_after_delim() {
fn test_strip_margins_alternate_delim() {
alternate_delimiter := ['This has a different delim,', 'but that is ok',
'because everything works',
].join('\n')
'because everything works'].join('\n')
alternate_delimiter_stripped := 'This has a different delim,
#but that is ok
#because everything works'.strip_margin_custom(`#`)
@ -48,8 +47,7 @@ fn test_strip_margins_multiple_delims_after_first() {
fn test_strip_margins_uneven_delims() {
uneven_delims := ["It doesn't matter if the delims are uneven,",
'The text will still be delimited correctly.', 'Maybe not everything needs 3 lines?',
'Let us go for 4 then',
].join('\n')
'Let us go for 4 then'].join('\n')
uneven_delims_stripped := "It doesn't matter if the delims are uneven,
|The text will still be delimited correctly.
|Maybe not everything needs 3 lines?
@ -59,8 +57,7 @@ fn test_strip_margins_uneven_delims() {
fn test_strip_margins_multiple_blank_lines() {
multi_blank_lines := ['Multiple blank lines will be removed.',
' I actually consider this a feature.',
].join('\n')
' I actually consider this a feature.'].join('\n')
multi_blank_lines_stripped := 'Multiple blank lines will be removed.

View File

@ -117,8 +117,7 @@ mut:
const (
atom_names = ['TARGETS', 'CLIPBOARD', 'PRIMARY', 'SECONDARY', 'TEXT', 'UTF8_STRING', 'text/plain',
'text/html',
]
'text/html']
)
// UNSUPPORTED TYPES: MULTIPLE, INCR, TIMESTAMP, image/bmp, image/jpeg, image/tiff, image/png

View File

@ -20,10 +20,11 @@ import crypto.sha512
// import crypto.blake2b_384
// import crypto.blake2b_512
const (
keys = [[byte(0xb), 0xb, 0xb, 0xb, 0xb, 0xb, 0xb, 0xb, 0xb, 0xb, 0xb, 0xb, 0xb, 0xb, 0xb, 0xb],
keys = [
[byte(0xb), 0xb, 0xb, 0xb, 0xb, 0xb, 0xb, 0xb, 0xb, 0xb, 0xb, 0xb, 0xb, 0xb, 0xb, 0xb],
'Jefe'.bytes(),
[byte(0xAA), 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
0xAA, 0xAA, 0xAA, 0xAA, 0xAA],
[byte(0xAA), 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
0xAA, 0xAA],
[byte(0x01), 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19],
[byte(0x0c), 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
@ -52,8 +53,7 @@ const (
0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd],
'Test With Truncation'.bytes(),
'Test Using Larger Than Block-Size Key - Hash Key First'.bytes(),
'Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data'.bytes(),
]
'Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data'.bytes()]
)
fn test_hmac_md5() {

View File

@ -42,8 +42,7 @@ pub fn system_font_path() string {
'FreeSans.ttf', 'DejaVuSans.ttf']
$if macos {
fonts = ['/System/Library/Fonts/SFNS.ttf', '/System/Library/Fonts/SFNSText.ttf',
'/Library/Fonts/Arial.ttf',
]
'/Library/Fonts/Arial.ttf']
for font in fonts {
if os.is_file(font) {
return font
@ -53,8 +52,7 @@ pub fn system_font_path() string {
$if android {
xml_files := ['/system/etc/system_fonts.xml', '/system/etc/fonts.xml',
'/etc/system_fonts.xml', '/etc/fonts.xml', '/data/fonts/fonts.xml',
'/etc/fallback_fonts.xml',
]
'/etc/fallback_fonts.xml']
font_locations := ['/system/fonts', '/data/fonts']
for xml_file in xml_files {
if os.is_file(xml_file) && os.is_readable(xml_file) {

View File

@ -12,8 +12,7 @@ const (
de_bruijn64tab = [byte(0), 1, 56, 2, 57, 49, 28, 3, 61, 58, 42, 50, 38, 29, 17, 4, 62, 47,
59, 36, 45, 43, 51, 22, 53, 39, 33, 30, 24, 18, 12, 5, 63, 55, 48, 27, 60, 41, 37, 16,
46, 35, 44, 21, 52, 32, 23, 11, 54, 26, 40, 15, 34, 20, 31, 10, 25, 14, 19, 9, 13, 8, 7,
6,
]
6]
)
const (

View File

@ -9,8 +9,7 @@ const (
vf_ = [f64(4.9790119248836735e+00), 7.7388724745781045e+00, -2.7688005719200159e-01,
-5.0106036182710749e+00, 9.6362937071984173e+00, 2.9263772392439646e+00,
5.2290834314593066e+00, 2.7279399104360102e+00, 1.8253080916808550e+00,
-8.6859247685756013e+00,
]
-8.6859247685756013e+00]
// The expected results below were computed by the high precision calculators
// at https://keisan.casio.com/. More exact input values (array vf_[], above)
// were obtained by printing them with "%.26f". The answers were calculated
@ -54,8 +53,7 @@ const (
ceil_ = [f64(5.0000000000000000e+00), 8.0000000000000000e+00, copysign(0, -1),
-5.0000000000000000e+00, 1.0000000000000000e+01, 3.0000000000000000e+00,
6.0000000000000000e+00, 3.0000000000000000e+00, 2.0000000000000000e+00,
-8.0000000000000000e+00,
]
-8.0000000000000000e+00]
cos_ = [f64(2.634752140995199110787593e-01), 1.148551260848219865642039e-01,
9.6191297325640768154550453e-01, 2.938141150061714816890637e-01,
-9.777138189897924126294461e-01, -9.7693041344303219127199518e-01,
@ -92,13 +90,11 @@ const (
fabs_ = [f64(4.9790119248836735e+00), 7.7388724745781045e+00, 2.7688005719200159e-01,
5.0106036182710749e+00, 9.6362937071984173e+00, 2.9263772392439646e+00,
5.2290834314593066e+00, 2.7279399104360102e+00, 1.8253080916808550e+00,
8.6859247685756013e+00,
]
8.6859247685756013e+00]
floor_ = [f64(4.0000000000000000e+00), 7.0000000000000000e+00, -1.0000000000000000e+00,
-6.0000000000000000e+00, 9.0000000000000000e+00, 2.0000000000000000e+00,
5.0000000000000000e+00, 2.0000000000000000e+00, 1.0000000000000000e+00,
-9.0000000000000000e+00,
]
-9.0000000000000000e+00]
fmod_ = [f64(4.197615023265299782906368e-02), 2.261127525421895434476482e+00,
3.231794108794261433104108e-02, 4.989396381728925078391512e+00,
3.637062928015826201999516e-01, 1.220868282268106064236690e+00,
@ -127,8 +123,7 @@ const (
logb_ = [f64(2.0000000000000000e+00), 2.0000000000000000e+00, -2.0000000000000000e+00,
2.0000000000000000e+00, 3.0000000000000000e+00, 1.0000000000000000e+00,
2.0000000000000000e+00, 1.0000000000000000e+00, 0.0000000000000000e+00,
3.0000000000000000e+00,
]
3.0000000000000000e+00]
log10_ = [f64(6.9714316642508290997617083e-01), 8.886776901739320576279124e-01,
-5.5770832400658929815908236e-01, 6.998900476822994346229723e-01,
9.8391002850684232013281033e-01, 4.6633031029295153334285302e-01,
@ -148,15 +143,13 @@ const (
[f64(7.0000000000000000e+00), 7.3887247457810456552351752e-01],
[f64(-0.0), -2.7688005719200159404635997e-01],
[f64(-5.0000000000000000e+00),
-1.060361827107492160848778e-02,
],
-1.060361827107492160848778e-02],
[f64(9.0000000000000000e+00), 6.3629370719841737980004837e-01],
[f64(2.0000000000000000e+00), 9.2637723924396464525443662e-01],
[f64(5.0000000000000000e+00), 2.2908343145930665230025625e-01],
[f64(2.0000000000000000e+00), 7.2793991043601025126008608e-01],
[f64(1.0000000000000000e+00), 8.2530809168085506044576505e-01],
[f64(-8.0000000000000000e+00), -6.8592476857560136238589621e-01],
]
[f64(-8.0000000000000000e+00), -6.8592476857560136238589621e-01]]
nextafter32_ = [4.979012489318848e+00, 7.738873004913330e+00, -2.768800258636475e-01,
-5.010602951049805e+00, 9.636294364929199e+00, 2.926377534866333e+00, 5.229084014892578e+00,
2.727940082550049e+00, 1.825308203697205e+00, -8.685923576354980e+00]
@ -215,8 +208,7 @@ const (
trunc_ = [f64(4.0000000000000000e+00), 7.0000000000000000e+00, copysign(0, -1),
-5.0000000000000000e+00, 9.0000000000000000e+00, 2.0000000000000000e+00,
5.0000000000000000e+00, 2.0000000000000000e+00, 1.0000000000000000e+00,
-8.0000000000000000e+00,
]
-8.0000000000000000e+00]
)
fn soclose(a f64, b f64, e_ f64) bool {
@ -305,8 +297,7 @@ fn test_atanh() {
assert veryclose(math.atanh_[i], f)
}
vfatanh_sc_ := [inf(-1), -pi, -1, copysign(0, -1), 0, 1, pi, inf(1),
nan(),
]
nan()]
atanh_sc_ := [nan(), nan(), inf(-1), copysign(0, -1), 0, inf(1),
nan(), nan(), nan()]
for i := 0; i < vfatanh_sc_.len; i++ {
@ -329,8 +320,7 @@ fn test_atan2() {
[f64(0), inf(1)], [f64(0), nan()], [pi, inf(-1)], [pi, 0],
[pi, inf(1)], [pi, nan()], [inf(1), inf(-1)], [inf(1), -pi],
[inf(1), 0], [inf(1), pi], [inf(1), inf(1)], [inf(1), nan()],
[nan(), nan()],
]
[nan(), nan()]]
atan2_sc_ := [f64(-3.0) * pi / 4.0, /* atan2(-inf, -inf) */ -pi / 2, /* atan2(-inf, -pi) */
-pi / 2,
/* atan2(-inf, +0) */ -pi / 2, /* atan2(-inf, pi) */ -pi / 4, /* atan2(-inf, +inf) */
@ -578,12 +568,10 @@ fn test_gamma() {
[f64(-5e-324), inf(-1)], [f64(-0.9999999999999999), -9.007199254740992e+15],
[f64(-1.0000000000000002), 4.5035996273704955e+15],
[f64(-1.9999999999999998),
2.2517998136852485e+15,
],
2.2517998136852485e+15],
[f64(-2.0000000000000004), -1.1258999068426235e+15],
[f64(-100.00000000000001),
-7.540083334883109e-145,
],
-7.540083334883109e-145],
[f64(-99.99999999999999), 7.540083334884096e-145], [f64(17), 2.0922789888e+13],
[f64(171), 7.257415615307999e+306], [f64(171.6), 1.5858969096672565e+308],
[f64(171.624), 1.7942117599248104e+308], [f64(171.625), inf(1)],
@ -595,9 +583,7 @@ fn test_gamma() {
[f64(-1.0000000003e+09), -0.0], [f64(-4.5035996273704955e+15), 0],
[f64(-63.349078729022985), 4.177797167776188e-88],
[f64(-127.45117632943295),
1.183111089623681e-214,
],
]
1.183111089623681e-214]]
_ := vfgamma_[0][0]
// @todo: Figure out solution for C backend
// for i := 0; i < math.vf_.len; i++ {
@ -623,18 +609,14 @@ fn test_hypot() {
assert veryclose(a, f)
}
vfhypot_sc_ := [[inf(-1), inf(-1)], [inf(-1), 0], [inf(-1),
inf(1),
],
inf(1)],
[inf(-1), nan()], [f64(-0.0), -0.0], [f64(-0.0), 0], [f64(0), -0.0],
[f64(0), 0], /* +0,0 */ [f64(0), inf(-1)], [f64(0), inf(1)],
[f64(0), nan()], [inf(1), inf(-1)], [inf(1), 0], [inf(1),
inf(1),
],
inf(1)],
[inf(1), nan()], [nan(), inf(-1)], [nan(), 0], [nan(),
inf(1),
],
[nan(), nan()],
]
inf(1)],
[nan(), nan()]]
hypot_sc_ := [inf(1), inf(1), inf(1), inf(1), 0, 0, 0, 0, inf(1),
inf(1), nan(), inf(1), inf(1), inf(1), inf(1), inf(1),
nan(), inf(1), nan()]
@ -660,8 +642,7 @@ fn test_ldexp() {
Fi{copysign(0, -1), -1075}, Fi{copysign(0, -1), 1024},
Fi{inf(1), 0}, Fi{inf(1), -1024}, Fi{inf(-1), 0}, Fi{inf(-1), -1024},
Fi{nan(), -1024}, Fi{10, 1 << (u64(sizeof(int) - 1) * 8)},
Fi{10, -(1 << (u64(sizeof(int) - 1) * 8))},
]
Fi{10, -(1 << (u64(sizeof(int) - 1) * 8))}]
ldexp_sc_ := [f64(0), 0, 0, copysign(0, -1), copysign(0, -1),
copysign(0, -1), inf(1), inf(1), inf(-1), inf(-1), nan(),
inf(1), 0]
@ -692,8 +673,7 @@ fn test_log() {
assert math.log_[i] == f
}
vflog_sc_ := [inf(-1), -pi, copysign(0, -1), 0, 1, inf(1),
nan(),
]
nan()]
log_sc_ := [nan(), nan(), inf(-1), inf(-1), 0, inf(1), nan()]
f := log(10)
assert f == ln10
@ -710,8 +690,7 @@ fn test_log10() {
assert veryclose(math.log10_[i], f)
}
vflog_sc_ := [inf(-1), -pi, copysign(0, -1), 0, 1, inf(1),
nan(),
]
nan()]
log_sc_ := [nan(), nan(), inf(-1), inf(-1), 0, inf(1), nan()]
for i := 0; i < vflog_sc_.len; i++ {
f := log10(vflog_sc_[i])
@ -740,8 +719,7 @@ fn test_pow() {
[pi, nan()], [inf(1), -pi], [inf(1), -0.0], [inf(1), 0],
[inf(1), 1], [inf(1), pi], [inf(1), nan()], [nan(), -pi],
[nan(), -0.0], [nan(), 0], [nan(), 1], [nan(), pi], [nan(),
nan(),
]]
nan()]]
pow_sc_ := [f64(0), /* pow(-inf, -pi) */ -0.0, /* pow(-inf, -3) */ 1, /* pow(-inf, -0) */ 1, /* pow(-inf, +0) */
inf(-1), /* pow(-inf, 1) */ inf(-1), /* pow(-inf, 3) */
inf(1), /* pow(-inf, pi) */ inf(1), /* pow(-inf, 0.5) */

View File

@ -6,8 +6,7 @@ const (
1e+23, 1e+24, 1e+25, 1e+26, 1e+27, 1e+28, 1e+29, 1e+30, 1e+31]
pow10postab32 = [f64(1e+00), 1e+32, 1e+64, 1e+96, 1e+128, 1e+160, 1e+192, 1e+224, 1e+256, 1e+288]
pow10negtab32 = [f64(1e-00), 1e-32, 1e-64, 1e-96, 1e-128, 1e-160, 1e-192, 1e-224, 1e-256, 1e-288,
1e-320,
]
1e-320]
)
// powf returns base raised to the provided power. (float32)

View File

@ -105,8 +105,7 @@ fn test_mode() {
mut o := stats.mode(data)
assert o == f64(2.7)
data = [f64(-3.0), f64(1.89), f64(1.89), f64(1.89), f64(9), f64(4.4), f64(4.4), f64(9),
f64(67.31),
]
f64(67.31)]
o = stats.mode(data)
assert o == f64(1.89)
// Testing greedy nature

View File

@ -131,12 +131,14 @@ pub fn resolve_addrs(addr string, family AddrFamily, @type SocketType) ?[]Addr {
C.memcpy(&resolved.path, addr.str, addr.len)
}
return [Addr{
f: u16(AddrFamily.unix)
addr: AddrData{
Unix: resolved
}
}]
return [
Addr{
f: u16(AddrFamily.unix)
addr: AddrData{
Unix: resolved
}
},
]
}
}
}

View File

@ -250,8 +250,7 @@ const (
&http.Cookie{
name: 'cookie-3'
value: 'v3'
},
]
}]
raw: 'cookie-1=v1; cookie-2=v2; cookie-3=v3'
},
]
@ -302,8 +301,7 @@ const (
path: '/'
http_only: true
raw: 'ASP.NET_SessionId=foo; path=/; HttpOnly'
},
]
}]
},
ReadSetCookiesTestCase{
header: {
@ -315,8 +313,7 @@ const (
value: 'foo'
same_site: .same_site_default_mode
raw: 'samesitedefault=foo; SameSite'
},
]
}]
},
ReadSetCookiesTestCase{
header: {
@ -328,8 +325,7 @@ const (
value: 'foo'
same_site: .same_site_lax_mode
raw: 'samesitelax=foo; SameSite=Lax'
},
]
}]
},
ReadSetCookiesTestCase{
header: {
@ -341,8 +337,7 @@ const (
value: 'foo'
same_site: .same_site_strict_mode
raw: 'samesitestrict=foo; SameSite=Strict'
},
]
}]
},
ReadSetCookiesTestCase{
header: {
@ -354,8 +349,7 @@ const (
value: 'foo'
same_site: .same_site_none_mode
raw: 'samesitenone=foo; SameSite=None'
},
]
}]
},
// Make sure we can properly read back the Set-Cookie headers we create
// for values containing spaces or commas:
@ -368,8 +362,7 @@ const (
name: 'special-1'
value: 'a z'
raw: 'special-1=a z'
},
]
}]
},
ReadSetCookiesTestCase{
header: {
@ -380,8 +373,7 @@ const (
name: 'special-2'
value: ' z'
raw: 'special-2=" z"'
},
]
}]
},
ReadSetCookiesTestCase{
header: {
@ -392,8 +384,7 @@ const (
name: 'special-3'
value: 'a '
raw: 'special-3="a "'
},
]
}]
},
ReadSetCookiesTestCase{
header: {
@ -404,8 +395,7 @@ const (
name: 'special-4'
value: ' '
raw: 'special-4=" "'
},
]
}]
},
ReadSetCookiesTestCase{
header: {
@ -416,8 +406,7 @@ const (
name: 'special-5'
value: 'a,z'
raw: 'special-5=a,z'
},
]
}]
},
ReadSetCookiesTestCase{
header: {
@ -428,8 +417,7 @@ const (
name: 'special-6'
value: ',z'
raw: 'special-6=",z"'
},
]
}]
},
ReadSetCookiesTestCase{
header: {
@ -440,8 +428,7 @@ const (
name: 'special-7'
value: ','
raw: 'special-8=","'
},
]
}]
}
// TODO(bradfitz): users have reported seeing this in the
// wild, but do browsers handle it? RFC 6265 just says "don't

View File

@ -64,8 +64,7 @@ pub fn (req &Request) do() ?Response {
qresp := req.method_and_url_to_response(req.method, rurl) ?
resp = qresp
if resp.status() !in [.moved_permanently, .found, .see_other, .temporary_redirect,
.permanent_redirect,
] {
.permanent_redirect] {
break
}
// follow any redirects

View File

@ -116,11 +116,13 @@ ${contents[1]}
"
form, files := parse_multipart_form(data, boundary)
assert files == {
names[0]: [FileData{
filename: file
content_type: ct
data: contents[0]
}]
names[0]: [
FileData{
filename: file
content_type: ct
data: contents[0]
},
]
}
assert form == {
@ -130,11 +132,13 @@ ${contents[1]}
fn test_multipart_form_body() {
files := {
'foo': [FileData{
filename: 'bar.v'
content_type: 'application/octet-stream'
data: 'baz'
}]
'foo': [
FileData{
filename: 'bar.v'
content_type: 'application/octet-stream'
data: 'baz'
},
]
}
form := {
'fooz': 'buzz'

View File

@ -54,8 +54,7 @@ fn should_escape(c byte, mode EncodingMode) bool {
// escape them (because hosts can`t use %-encoding for
// ASCII bytes).
if c in [`!`, `$`, `&`, `\\`, `(`, `)`, `*`, `+`, `,`, `;`, `=`, `:`, `[`, `]`, `<`, `>`,
`"`,
] {
`"`] {
return false
}
}

View File

@ -9,8 +9,7 @@ const (
error = 0.05
// The seeds used (for reproducible testing)
seeds = [[u32(0xffff24), 0xabcd], [u32(0x141024), 0x42851],
[u32(0x1452), 0x90cd],
]
[u32(0x1452), 0x90cd]]
)
fn test_bernoulli() {

View File

@ -1215,8 +1215,7 @@ fn (mut re RE) impl_compile(in_txt string) (int, int) {
return regex.err_syntax_error, 0
}
if re.prog[pc2].ist !in [rune(regex.ist_prog_end), regex.ist_group_end,
regex.ist_group_start,
] {
regex.ist_group_start] {
// println("Next dot char check is PC: ${pc2}")
re.prog[pc1].dot_check_pc = pc2
break

View File

@ -201,8 +201,7 @@ pub struct Config {
skip_init_checks bool
// All kill signals to set up exit listeners on:
reset []os.Signal = [.hup, .int, .quit, .ill, .abrt, .bus, .fpe, .kill, .segv, .pipe, .alrm, .term,
.stop,
]
.stop]
}
[inline]

View File

@ -31,8 +31,7 @@ pub const (
31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + 31,
]
long_days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday',
'Sunday',
]
'Sunday']
)
// Time contains various time units for a point in time.

View File

@ -101,8 +101,7 @@ fn test_format_ss_micro() {
fn test_smonth() {
month_names := ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov',
'Dec',
]
'Dec']
for i, name in month_names {
month_num := i + 1
t := time.Time{

View File

@ -429,11 +429,9 @@ pub const (
byte_type_idx, u8_type_idx, u16_type_idx, u32_type_idx, u64_type_idx, isize_type_idx,
usize_type_idx, int_literal_type_idx, rune_type_idx]
signed_integer_type_idxs = [i8_type_idx, i16_type_idx, int_type_idx, i64_type_idx,
isize_type_idx,
]
isize_type_idx]
unsigned_integer_type_idxs = [byte_type_idx, u16_type_idx, u32_type_idx, u64_type_idx,
usize_type_idx,
]
usize_type_idx]
float_type_idxs = [f32_type_idx, f64_type_idx, float_literal_type_idx]
number_type_idxs = [i8_type_idx, i16_type_idx, int_type_idx, i64_type_idx,
byte_type_idx, u16_type_idx, u32_type_idx, u64_type_idx, isize_type_idx, usize_type_idx,
@ -710,8 +708,7 @@ pub fn (t &TypeSymbol) is_pointer() bool {
[inline]
pub fn (t &TypeSymbol) is_int() bool {
res := t.kind in [.i8, .i16, .int, .i64, .isize, .byte, .u16, .u32, .u64, .usize, .int_literal,
.rune,
]
.rune]
if !res && t.kind == .alias {
return (t.info as Alias).parent_type.is_number()
}

View File

@ -799,8 +799,7 @@ fn (mut b Builder) cc_linux_cross() {
'-o $b.pref.out_name', '-m elf_x86_64',
'-dynamic-linker /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2',
'$sysroot/crt1.o $sysroot/crti.o $obj_file', '-lc', '-lcrypto', '-lssl', '-lpthread',
'$sysroot/crtn.o',
]
'$sysroot/crtn.o']
linker_args << cflags.c_options_only_object_files()
// -ldl
b.dump_c_options(linker_args)

View File

@ -132,9 +132,15 @@ fn test_all() {
'custom_comptime_define_if_flag.vv',
])
ct_tasks.add_checked_run('run', '.run.out', ['custom_comptime_define_if_debug.vv'])
ct_tasks.add_checked_run('-g run', '.g.run.out', ['custom_comptime_define_if_debug.vv'])
ct_tasks.add_checked_run('-cg run', '.cg.run.out', ['custom_comptime_define_if_debug.vv'])
ct_tasks.add_checked_run('-d debug run', '.debug.run.out', ['custom_comptime_define_if_debug.vv'])
ct_tasks.add_checked_run('-g run', '.g.run.out', [
'custom_comptime_define_if_debug.vv',
])
ct_tasks.add_checked_run('-cg run', '.cg.run.out', [
'custom_comptime_define_if_debug.vv',
])
ct_tasks.add_checked_run('-d debug run', '.debug.run.out', [
'custom_comptime_define_if_debug.vv',
])
ct_tasks.add_checked_run('-d debug -d bar run', '.debug.bar.run.out', [
'custom_comptime_define_if_debug.vv',
])

View File

@ -1377,6 +1377,7 @@ pub fn (mut f Fmt) array_init(node ast.ArrayInit) {
if i == 0 {
if f.array_init_depth > f.array_init_break.len {
f.array_init_break << pos.line_nr > last_line_nr
|| f.line_len + expr.position().len > fmt.max_len[3]
}
}
line_break := f.array_init_break[f.array_init_depth - 1]
@ -1462,7 +1463,10 @@ pub fn (mut f Fmt) array_init(node ast.ArrayInit) {
}
last_comment_was_inline = cmt.is_inline
}
} else if i == node.exprs.len - 1 && !line_break {
is_new_line = false
}
mut put_comma := !set_comma
if has_comments && !last_comment_was_inline {
put_comma = false
@ -2348,8 +2352,12 @@ pub fn (mut f Fmt) string_literal(node ast.StringLiteral) {
f.write("'$node.val'")
}
} else {
unescaped_val := node.val.replace('$fmt.bs$fmt.bs', '\x01').replace_each(["$fmt.bs'", "'",
'$fmt.bs"', '"'])
unescaped_val := node.val.replace('$fmt.bs$fmt.bs', '\x01').replace_each([
"$fmt.bs'",
"'",
'$fmt.bs"',
'"',
])
if use_double_quote {
s := unescaped_val.replace_each(['\x01', '$fmt.bs$fmt.bs', '"', '$fmt.bs"'])
f.write('"$s"')

View File

@ -11,8 +11,7 @@ const (
name: 'special-7'
value: ','
raw: 'special-8=","'
},
]
}]
}
// (bradfitz): users have reported seeing this in the
// wild, but do browsers handle it? RFC 6265 just says "don't

View File

@ -11,8 +11,7 @@ fn wrapping_tests() {
my_arr := ['Lorem ipsum dolor sit amet, consectetur adipiscing',
'elit. Donec varius purus leo, vel maximus diam',
'finibus sed. Etiam eu urna ante. Nunc quis vehicula',
'velit. Sed at mauris et quam ornare tristique.',
]
'velit. Sed at mauris et quam ornare tristique.']
}
fn array_init_without_commas() {

View File

@ -0,0 +1,6 @@
fn main() {
if ['aaaaaaaaaaaaaaaaaaa', 'bbbbbbbbbbbbbbbbbbbbbbb', 'ccccccccccccccccccccccccc',
'dddddddddddddddddddddd'].contains('foo')
{
}
}

View File

@ -0,0 +1,3 @@
fn main() {
if ['aaaaaaaaaaaaaaaaaaa','bbbbbbbbbbbbbbbbbbbbbbb','ccccccccccccccccccccccccc','dddddddddddddddddddddd'].contains('foo'){}
}

View File

@ -4017,8 +4017,7 @@ fn (mut g Gen) match_expr(node ast.MatchExpr) {
g.inside_ternary++
}
if node.cond in [ast.Ident, ast.SelectorExpr, ast.IntegerLiteral, ast.StringLiteral,
ast.FloatLiteral,
] {
ast.FloatLiteral] {
cond_var = g.expr_string(node.cond)
} else {
line := if is_expr {

View File

@ -1165,11 +1165,13 @@ fn (mut g Gen) autofree_call_pregen(node ast.CallExpr) {
g.tmp_count2++
mut scope := g.file.scope.innermost(node.pos.pos)
// prepend the receiver for now (TODO turn the receiver into a CallArg everywhere?)
mut args := [ast.CallArg{
typ: node.receiver_type
expr: node.left
is_tmp_autofree: node.free_receiver
}]
mut args := [
ast.CallArg{
typ: node.receiver_type
expr: node.left
is_tmp_autofree: node.free_receiver
},
]
args << node.args
// for i, arg in node.args {
for i, arg in args {

View File

@ -295,8 +295,7 @@ fn js_dec_name(typ string) string {
fn is_js_prim(typ string) bool {
return typ in ['int', 'string', 'bool', 'f32', 'f64', 'i8', 'i16', 'i64', 'u16', 'u32', 'u64',
'byte',
]
'byte']
}
fn (mut g Gen) decode_array(value_type ast.Type) string {

View File

@ -1093,8 +1093,7 @@ fn (mut g JsGen) gen_assign_stmt(stmt ast.AssignStmt, semicolon bool) {
}
is_assign := stmt.op in [.plus_assign, .minus_assign, .mult_assign, .div_assign,
.xor_assign, .mod_assign, .or_assign, .and_assign, .right_shift_assign,
.left_shift_assign,
]
.left_shift_assign]
val := stmt.right[i]
mut is_mut := false

View File

@ -1072,19 +1072,22 @@ fn main() {
'aaa': '111'
}
}
people := [Person{
name: 'ivan'
nums: [1, 2, 3]
kv: {
'aaa': '111'
}
}, Person{
name: 'bob'
nums: [2]
kv: {
'bbb': '222'
}
}]
people := [
Person{
name: 'ivan'
nums: [1, 2, 3]
kv: {
'aaa': '111'
}
},
Person{
name: 'bob'
nums: [2]
kv: {
'bbb': '222'
}
},
]
println(ivan in people)
}
{
@ -1096,19 +1099,22 @@ fn main() {
'aaa': '111'
}
}
people := [Person{
name: 'ivan'
nums: [1, 2, 3]
kv: {
'aaa': '111'
}
}, Person{
name: 'bob'
nums: [2]
kv: {
'bbb': '222'
}
}]
people := [
Person{
name: 'ivan'
nums: [1, 2, 3]
kv: {
'aaa': '111'
}
},
Person{
name: 'bob'
nums: [2]
kv: {
'bbb': '222'
}
},
]
println(people.index(ivan))
assert people.index(ivan) == 0
}

View File

@ -348,8 +348,7 @@ pub fn mark_used(mut table ast.Table, pref &pref.Preferences, ast_files []&ast.F
if pref.gc_mode in [.boehm_full_opt, .boehm_incr_opt] {
if k in ['new_map_noscan_key', 'new_map_noscan_value', 'new_map_noscan_key_value',
'new_map_init_noscan_key', 'new_map_init_noscan_value',
'new_map_init_noscan_key_value',
] {
'new_map_init_noscan_key_value'] {
walker.fn_decl(mut mfn)
}
}

View File

@ -984,8 +984,7 @@ fn (mut p Parser) closure_vars() []ast.Param {
fn (mut p Parser) check_fn_mutable_arguments(typ ast.Type, pos token.Position) {
sym := p.table.get_type_symbol(typ)
if sym.kind in [.array, .array_fixed, .interface_, .map, .placeholder, .struct_, .generic_inst,
.sum_type,
] {
.sum_type] {
return
}
if typ.is_ptr() || typ.is_pointer() {

View File

@ -528,12 +528,14 @@ fn (mut p Parser) interface_decl() ast.InterfaceDecl {
}
// field_names << name
args2, _, is_variadic := p.fn_args() // TODO merge ast.Param and ast.Arg to avoid this
mut args := [ast.Param{
name: 'x'
is_mut: is_mut
typ: typ
is_hidden: true
}]
mut args := [
ast.Param{
name: 'x'
is_mut: is_mut
typ: typ
is_hidden: true
},
]
args << args2
mut method := ast.FnDecl{
name: name

View File

@ -53,8 +53,7 @@ fn test_samples() {
'-pthread', '-lglib-2.0', '-lpcre']
assert x.libs_private == ['-ldl', '-pthread']
assert x.cflags == ['-I/usr/include', '-pthread', '-I/usr/include/glib-2.0',
'-I/usr/lib/x86_64-linux-gnu/glib-2.0/include',
]
'-I/usr/lib/x86_64-linux-gnu/glib-2.0/include']
assert x.vars == {
'prefix': '/usr'
'libdir': '/usr/lib/x86_64-linux-gnu'

View File

@ -27,8 +27,7 @@ fn cast<T>(obj Any) ?T {
fn test_any_values() {
arr := [make_any(true), make_any(false), make_any(7), make_any('cat'),
make_any([3.1415926535]),
]
make_any([3.1415926535])]
for elm in arr {
if b := cast<bool>(elm) {
println(!b)

View File

@ -330,8 +330,7 @@ pub fn is_key(key string) bool {
[inline]
pub fn is_decl(t Kind) bool {
return t in [.key_enum, .key_interface, .key_fn, .key_struct, .key_type, .key_const, .key_pub,
.eof,
]
.eof]
}
[inline]

View File

@ -117,11 +117,13 @@ ${contents[1]}
"
form, files := http.parse_multipart_form(data, boundary)
assert files == {
names[0]: [http.FileData{
filename: file
content_type: ct
data: contents[0]
}]
names[0]: [
http.FileData{
filename: file
content_type: ct
data: contents[0]
},
]
}
assert form == {