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 mut failed := false
v_build_commands := ['$vexe -o v_g -g cmd/v', '$vexe -o v_prod_g -prod -g cmd/v', 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_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() mut bmark := benchmark.new_benchmark()
for cmd in v_build_commands { for cmd in v_build_commands {
bmark.step() bmark.step()

View File

@ -56,15 +56,18 @@ fn (c Context) compare_versions() {
'v @DEBUG@ -o source.c examples/hello_world.v', 'v @DEBUG@ -o source.c examples/hello_world.v',
'v -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@', perf_files << c.compare_v_performance('source_v', [
'vprod -o source.c @COMPILER@', 'v @DEBUG@ -o source.c @COMPILER@', 'vprod @DEBUG@ -o source.c @COMPILER@',
'vprod -o source.c @COMPILER@',
'v @DEBUG@ -o source.c @COMPILER@',
'v -o source.c @COMPILER@', 'v -o source.c @COMPILER@',
]) ])
perf_files << c.compare_v_performance('binary_hello', [ perf_files << c.compare_v_performance('binary_hello', [
'vprod -o hello examples/hello_world.v', 'vprod -o hello examples/hello_world.v',
'v -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@', 'v -o binary @COMPILER@',
]) ])
println('All performance files:') 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/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/v', '$cdir/v_stripped', '$cdir/v_stripped_upxed'])
scripting.show_sizes_of_files(['$cdir/vprod', '$cdir/vprod_stripped', scripting.show_sizes_of_files(['$cdir/vprod', '$cdir/vprod_stripped',
'$cdir/vprod_stripped_upxed', '$cdir/vprod_stripped_upxed'])
])
vversion := scripting.run('$cdir/v -version') vversion := scripting.run('$cdir/v -version')
vcommit := scripting.run('git rev-parse --short --verify HEAD') vcommit := scripting.run('git rev-parse --short --verify HEAD')
println('V version is: $vversion , local source commit: $vcommit') 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 { .string {
use_double_quote := tok.lit.contains("'") && !tok.lit.contains('"') use_double_quote := tok.lit.contains("'") && !tok.lit.contains('"')
unescaped_val := tok.lit.replace('\\\\', '\x01').replace_each(["\\'", "'", '\\"', unescaped_val := tok.lit.replace('\\\\', '\x01').replace_each(["\\'", "'", '\\"',
'"', '"'])
])
if use_double_quote { if use_double_quote {
s := unescaped_val.replace_each(['\x01', '\\\\', '"', '\\"']) s := unescaped_val.replace_each(['\x01', '\\\\', '"', '\\"'])
lit = term.yellow('"$s"') lit = term.yellow('"$s"')

View File

@ -289,11 +289,9 @@ fn (mut vd VDoc) generate_docs_from_file() {
} }
} }
} }
dirs := if cfg.is_multi { dirs := if cfg.is_multi { get_modules_list(cfg.input_path, []string{}) } else { [
get_modules_list(cfg.input_path, []string{}) cfg.input_path,
} else { ] }
[cfg.input_path]
}
for dirpath in dirs { for dirpath in dirs {
vd.vprintln('Generating $out.typ docs for "$dirpath"') vd.vprintln('Generating $out.typ docs for "$dirpath"')
mut dcs := doc.generate(dirpath, cfg.pub_only, true, cfg.platform, cfg.symbol_name) or { 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) { fn frame(mut app App) {
app.gg.begin() 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, 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, 300.0], gx.blue)
], 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_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.draw_triangle(450, 142, 530, 280, 370, 280, gx.red)
app.gg.end() app.gg.end()

View File

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

View File

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

View File

@ -119,8 +119,7 @@ fn test_window() {
x := [1, 2, 3, 4, 5, 6] x := [1, 2, 3, 4, 5, 6]
assert window<int>(x, size: 3) == [[1, 2, 3], [2, 3, 4], [3, 4, 5], 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>(x, size: 3, step: 2) == [[1, 2, 3], [3, 4, 5]]
assert window<int>([]int{}, size: 2) == [][]int{} 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_1[0][0][1] = 0
a3_2[0][1][0] = 0 a3_2[0][1][0] = 0
assert a3_1 == [[[1, 0], [2, 2], [3, 3]], [[4, 4], [5, 5], 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], assert a3_2 == [[[1, 1], [0, 2], [3, 3]], [[4, 4], [5, 5],
[6, 6], [6, 6]]]
]]
// 3d array_string // 3d array_string
mut b3_1 := [[['1', '1'], ['2', '2'], ['3', '3']], [['4', '4'], mut b3_1 := [[['1', '1'], ['2', '2'], ['3', '3']], [['4', '4'],
['5', '5'], ['6', '6']]] ['5', '5'], ['6', '6']]]
@ -1339,19 +1337,22 @@ fn test_struct_array_of_multi_type_in() {
'aaa': '111' 'aaa': '111'
} }
} }
people := [Person{ people := [
name: 'ivan' Person{
nums: [1, 2, 3] name: 'ivan'
kv: { nums: [1, 2, 3]
'aaa': '111' kv: {
} 'aaa': '111'
}, Person{ }
name: 'bob' },
nums: [2] Person{
kv: { name: 'bob'
'bbb': '222' nums: [2]
} kv: {
}] 'bbb': '222'
}
},
]
println(ivan in people) println(ivan in people)
assert ivan in people assert ivan in people
} }
@ -1364,19 +1365,22 @@ fn test_struct_array_of_multi_type_index() {
'aaa': '111' 'aaa': '111'
} }
} }
people := [Person{ people := [
name: 'ivan' Person{
nums: [1, 2, 3] name: 'ivan'
kv: { nums: [1, 2, 3]
'aaa': '111' kv: {
} 'aaa': '111'
}, Person{ }
name: 'bob' },
nums: [2] Person{
kv: { name: 'bob'
'bbb': '222' nums: [2]
} kv: {
}] 'bbb': '222'
}
},
]
println(people.index(ivan)) println(people.index(ivan))
assert people.index(ivan) == 0 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() { fn test_strip_margins_alternate_delim() {
alternate_delimiter := ['This has a different delim,', 'but that is ok', alternate_delimiter := ['This has a different delim,', 'but that is ok',
'because everything works', 'because everything works'].join('\n')
].join('\n')
alternate_delimiter_stripped := 'This has a different delim, alternate_delimiter_stripped := 'This has a different delim,
#but that is ok #but that is ok
#because everything works'.strip_margin_custom(`#`) #because everything works'.strip_margin_custom(`#`)
@ -48,8 +47,7 @@ fn test_strip_margins_multiple_delims_after_first() {
fn test_strip_margins_uneven_delims() { fn test_strip_margins_uneven_delims() {
uneven_delims := ["It doesn't matter if the delims are uneven,", uneven_delims := ["It doesn't matter if the delims are uneven,",
'The text will still be delimited correctly.', 'Maybe not everything needs 3 lines?', 'The text will still be delimited correctly.', 'Maybe not everything needs 3 lines?',
'Let us go for 4 then', 'Let us go for 4 then'].join('\n')
].join('\n')
uneven_delims_stripped := "It doesn't matter if the delims are uneven, uneven_delims_stripped := "It doesn't matter if the delims are uneven,
|The text will still be delimited correctly. |The text will still be delimited correctly.
|Maybe not everything needs 3 lines? |Maybe not everything needs 3 lines?
@ -59,8 +57,7 @@ fn test_strip_margins_uneven_delims() {
fn test_strip_margins_multiple_blank_lines() { fn test_strip_margins_multiple_blank_lines() {
multi_blank_lines := ['Multiple blank lines will be removed.', multi_blank_lines := ['Multiple blank lines will be removed.',
' I actually consider this a feature.', ' I actually consider this a feature.'].join('\n')
].join('\n')
multi_blank_lines_stripped := 'Multiple blank lines will be removed. multi_blank_lines_stripped := 'Multiple blank lines will be removed.

View File

@ -117,8 +117,7 @@ mut:
const ( const (
atom_names = ['TARGETS', 'CLIPBOARD', 'PRIMARY', 'SECONDARY', 'TEXT', 'UTF8_STRING', 'text/plain', 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 // 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_384
// import crypto.blake2b_512 // import crypto.blake2b_512
const ( 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(), 'Jefe'.bytes(),
[byte(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, 0xAA, 0xAA, 0xAA], 0xAA, 0xAA],
[byte(0x01), 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, [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], 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, [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], 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd],
'Test With Truncation'.bytes(), 'Test With Truncation'.bytes(),
'Test Using Larger Than Block-Size Key - Hash Key First'.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() { fn test_hmac_md5() {

View File

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

View File

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

View File

@ -105,8 +105,7 @@ fn test_mode() {
mut o := stats.mode(data) mut o := stats.mode(data)
assert o == f64(2.7) 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), 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) o = stats.mode(data)
assert o == f64(1.89) assert o == f64(1.89)
// Testing greedy nature // 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) C.memcpy(&resolved.path, addr.str, addr.len)
} }
return [Addr{ return [
f: u16(AddrFamily.unix) Addr{
addr: AddrData{ f: u16(AddrFamily.unix)
Unix: resolved addr: AddrData{
} Unix: resolved
}] }
},
]
} }
} }
} }

View File

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

View File

@ -116,11 +116,13 @@ ${contents[1]}
" "
form, files := parse_multipart_form(data, boundary) form, files := parse_multipart_form(data, boundary)
assert files == { assert files == {
names[0]: [FileData{ names[0]: [
filename: file FileData{
content_type: ct filename: file
data: contents[0] content_type: ct
}] data: contents[0]
},
]
} }
assert form == { assert form == {
@ -130,11 +132,13 @@ ${contents[1]}
fn test_multipart_form_body() { fn test_multipart_form_body() {
files := { files := {
'foo': [FileData{ 'foo': [
filename: 'bar.v' FileData{
content_type: 'application/octet-stream' filename: 'bar.v'
data: 'baz' content_type: 'application/octet-stream'
}] data: 'baz'
},
]
} }
form := { form := {
'fooz': 'buzz' '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 // escape them (because hosts can`t use %-encoding for
// ASCII bytes). // ASCII bytes).
if c in [`!`, `$`, `&`, `\\`, `(`, `)`, `*`, `+`, `,`, `;`, `=`, `:`, `[`, `]`, `<`, `>`, if c in [`!`, `$`, `&`, `\\`, `(`, `)`, `*`, `+`, `,`, `;`, `=`, `:`, `[`, `]`, `<`, `>`,
`"`, `"`] {
] {
return false return false
} }
} }

View File

@ -9,8 +9,7 @@ const (
error = 0.05 error = 0.05
// The seeds used (for reproducible testing) // The seeds used (for reproducible testing)
seeds = [[u32(0xffff24), 0xabcd], [u32(0x141024), 0x42851], seeds = [[u32(0xffff24), 0xabcd], [u32(0x141024), 0x42851],
[u32(0x1452), 0x90cd], [u32(0x1452), 0x90cd]]
]
) )
fn test_bernoulli() { 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 return regex.err_syntax_error, 0
} }
if re.prog[pc2].ist !in [rune(regex.ist_prog_end), regex.ist_group_end, 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}") // println("Next dot char check is PC: ${pc2}")
re.prog[pc1].dot_check_pc = pc2 re.prog[pc1].dot_check_pc = pc2
break break

View File

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

View File

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

View File

@ -101,8 +101,7 @@ fn test_format_ss_micro() {
fn test_smonth() { fn test_smonth() {
month_names := ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', month_names := ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov',
'Dec', 'Dec']
]
for i, name in month_names { for i, name in month_names {
month_num := i + 1 month_num := i + 1
t := time.Time{ 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, 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] 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, 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, 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] 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, 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, 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] [inline]
pub fn (t &TypeSymbol) is_int() bool { pub fn (t &TypeSymbol) is_int() bool {
res := t.kind in [.i8, .i16, .int, .i64, .isize, .byte, .u16, .u32, .u64, .usize, .int_literal, res := t.kind in [.i8, .i16, .int, .i64, .isize, .byte, .u16, .u32, .u64, .usize, .int_literal,
.rune, .rune]
]
if !res && t.kind == .alias { if !res && t.kind == .alias {
return (t.info as Alias).parent_type.is_number() 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', '-o $b.pref.out_name', '-m elf_x86_64',
'-dynamic-linker /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2', '-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/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() linker_args << cflags.c_options_only_object_files()
// -ldl // -ldl
b.dump_c_options(linker_args) b.dump_c_options(linker_args)

View File

@ -132,9 +132,15 @@ fn test_all() {
'custom_comptime_define_if_flag.vv', '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('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('-g run', '.g.run.out', [
ct_tasks.add_checked_run('-cg run', '.cg.run.out', ['custom_comptime_define_if_debug.vv']) '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('-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', [ ct_tasks.add_checked_run('-d debug -d bar run', '.debug.bar.run.out', [
'custom_comptime_define_if_debug.vv', '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 i == 0 {
if f.array_init_depth > f.array_init_break.len { if f.array_init_depth > f.array_init_break.len {
f.array_init_break << pos.line_nr > last_line_nr 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] 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 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 mut put_comma := !set_comma
if has_comments && !last_comment_was_inline { if has_comments && !last_comment_was_inline {
put_comma = false put_comma = false
@ -2348,8 +2352,12 @@ pub fn (mut f Fmt) string_literal(node ast.StringLiteral) {
f.write("'$node.val'") f.write("'$node.val'")
} }
} else { } else {
unescaped_val := node.val.replace('$fmt.bs$fmt.bs', '\x01').replace_each(["$fmt.bs'", "'", unescaped_val := node.val.replace('$fmt.bs$fmt.bs', '\x01').replace_each([
'$fmt.bs"', '"']) "$fmt.bs'",
"'",
'$fmt.bs"',
'"',
])
if use_double_quote { if use_double_quote {
s := unescaped_val.replace_each(['\x01', '$fmt.bs$fmt.bs', '"', '$fmt.bs"']) s := unescaped_val.replace_each(['\x01', '$fmt.bs$fmt.bs', '"', '$fmt.bs"'])
f.write('"$s"') f.write('"$s"')

View File

@ -11,8 +11,7 @@ const (
name: 'special-7' name: 'special-7'
value: ',' value: ','
raw: 'special-8=","' raw: 'special-8=","'
}, }]
]
} }
// (bradfitz): users have reported seeing this in the // (bradfitz): users have reported seeing this in the
// wild, but do browsers handle it? RFC 6265 just says "don't // 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', my_arr := ['Lorem ipsum dolor sit amet, consectetur adipiscing',
'elit. Donec varius purus leo, vel maximus diam', 'elit. Donec varius purus leo, vel maximus diam',
'finibus sed. Etiam eu urna ante. Nunc quis vehicula', '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() { 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++ g.inside_ternary++
} }
if node.cond in [ast.Ident, ast.SelectorExpr, ast.IntegerLiteral, ast.StringLiteral, if node.cond in [ast.Ident, ast.SelectorExpr, ast.IntegerLiteral, ast.StringLiteral,
ast.FloatLiteral, ast.FloatLiteral] {
] {
cond_var = g.expr_string(node.cond) cond_var = g.expr_string(node.cond)
} else { } else {
line := if is_expr { line := if is_expr {

View File

@ -1165,11 +1165,13 @@ fn (mut g Gen) autofree_call_pregen(node ast.CallExpr) {
g.tmp_count2++ g.tmp_count2++
mut scope := g.file.scope.innermost(node.pos.pos) mut scope := g.file.scope.innermost(node.pos.pos)
// prepend the receiver for now (TODO turn the receiver into a CallArg everywhere?) // prepend the receiver for now (TODO turn the receiver into a CallArg everywhere?)
mut args := [ast.CallArg{ mut args := [
typ: node.receiver_type ast.CallArg{
expr: node.left typ: node.receiver_type
is_tmp_autofree: node.free_receiver expr: node.left
}] is_tmp_autofree: node.free_receiver
},
]
args << node.args args << node.args
// for i, arg in node.args { // for i, arg in node.args {
for i, arg in 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 { fn is_js_prim(typ string) bool {
return typ in ['int', 'string', 'bool', 'f32', 'f64', 'i8', 'i16', 'i64', 'u16', 'u32', 'u64', 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 { 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, is_assign := stmt.op in [.plus_assign, .minus_assign, .mult_assign, .div_assign,
.xor_assign, .mod_assign, .or_assign, .and_assign, .right_shift_assign, .xor_assign, .mod_assign, .or_assign, .and_assign, .right_shift_assign,
.left_shift_assign, .left_shift_assign]
]
val := stmt.right[i] val := stmt.right[i]
mut is_mut := false mut is_mut := false

View File

@ -1072,19 +1072,22 @@ fn main() {
'aaa': '111' 'aaa': '111'
} }
} }
people := [Person{ people := [
name: 'ivan' Person{
nums: [1, 2, 3] name: 'ivan'
kv: { nums: [1, 2, 3]
'aaa': '111' kv: {
} 'aaa': '111'
}, Person{ }
name: 'bob' },
nums: [2] Person{
kv: { name: 'bob'
'bbb': '222' nums: [2]
} kv: {
}] 'bbb': '222'
}
},
]
println(ivan in people) println(ivan in people)
} }
{ {
@ -1096,19 +1099,22 @@ fn main() {
'aaa': '111' 'aaa': '111'
} }
} }
people := [Person{ people := [
name: 'ivan' Person{
nums: [1, 2, 3] name: 'ivan'
kv: { nums: [1, 2, 3]
'aaa': '111' kv: {
} 'aaa': '111'
}, Person{ }
name: 'bob' },
nums: [2] Person{
kv: { name: 'bob'
'bbb': '222' nums: [2]
} kv: {
}] 'bbb': '222'
}
},
]
println(people.index(ivan)) println(people.index(ivan))
assert people.index(ivan) == 0 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 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', 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', 'new_map_init_noscan_value',
'new_map_init_noscan_key_value', 'new_map_init_noscan_key_value'] {
] {
walker.fn_decl(mut mfn) 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) { fn (mut p Parser) check_fn_mutable_arguments(typ ast.Type, pos token.Position) {
sym := p.table.get_type_symbol(typ) sym := p.table.get_type_symbol(typ)
if sym.kind in [.array, .array_fixed, .interface_, .map, .placeholder, .struct_, .generic_inst, if sym.kind in [.array, .array_fixed, .interface_, .map, .placeholder, .struct_, .generic_inst,
.sum_type, .sum_type] {
] {
return return
} }
if typ.is_ptr() || typ.is_pointer() { if typ.is_ptr() || typ.is_pointer() {

View File

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

View File

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

View File

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

View File

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

View File

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