mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
all: string interpolation fixes
This commit is contained in:
parent
d653716292
commit
cc58d6a919
@ -165,8 +165,8 @@ fn (mut context Context) parse_options() ! {
|
|||||||
context.verbose = fp.bool('verbose', `v`, false, 'Be more verbose.')
|
context.verbose = fp.bool('verbose', `v`, false, 'Be more verbose.')
|
||||||
context.fail_on_maxtime = fp.int('max_time', `m`, max_time, 'Fail with exit code 2, when first cmd takes above M milliseconds (regression).')
|
context.fail_on_maxtime = fp.int('max_time', `m`, max_time, 'Fail with exit code 2, when first cmd takes above M milliseconds (regression).')
|
||||||
context.fail_on_regress_percent = fp.int('fail_percent', `f`, max_fail_percent, 'Fail with exit code 3, when first cmd is X% slower than the rest (regression).')
|
context.fail_on_regress_percent = fp.int('fail_percent', `f`, max_fail_percent, 'Fail with exit code 3, when first cmd is X% slower than the rest (regression).')
|
||||||
context.cmd_template = fp.string('template', `t`, '{T}', 'Command template. {T} will be substituted with the current command.')
|
context.cmd_template = fp.string('template', `t`, r'{T}', r'Command template. {T} will be substituted with the current command.')
|
||||||
cmd_params := fp.string_multi('parameter', `p`, 'A parameter substitution list. `{p}=val1,val2,val2` means that {p} in the template, will be substituted with each of val1, val2, val3.')
|
cmd_params := fp.string_multi('parameter', `p`, r'A parameter substitution list. `{p}=val1,val2,val2` means that {p} in the template, will be substituted with each of val1, val2, val3.')
|
||||||
context.nmins = fp.int('nmins', `i`, 0, 'Ignore the BOTTOM X results (minimum execution time). Makes the results more robust to performance flukes.')
|
context.nmins = fp.int('nmins', `i`, 0, 'Ignore the BOTTOM X results (minimum execution time). Makes the results more robust to performance flukes.')
|
||||||
context.nmaxs = fp.int('nmaxs', `a`, 1, 'Ignore the TOP X results (maximum execution time). Makes the results more robust to performance flukes.')
|
context.nmaxs = fp.int('nmaxs', `a`, 1, 'Ignore the TOP X results (maximum execution time). Makes the results more robust to performance flukes.')
|
||||||
for p in cmd_params {
|
for p in cmd_params {
|
||||||
@ -212,7 +212,7 @@ fn (mut context Context) clear_line() {
|
|||||||
fn (mut context Context) expand_all_commands(commands []string) []string {
|
fn (mut context Context) expand_all_commands(commands []string) []string {
|
||||||
mut all_commands := []string{}
|
mut all_commands := []string{}
|
||||||
for cmd in commands {
|
for cmd in commands {
|
||||||
maincmd := context.cmd_template.replace('{T}', cmd)
|
maincmd := context.cmd_template.replace(r'{T}', cmd)
|
||||||
mut substituted_commands := []string{}
|
mut substituted_commands := []string{}
|
||||||
substituted_commands << maincmd
|
substituted_commands << maincmd
|
||||||
for paramk, paramlist in context.cmd_params {
|
for paramk, paramlist in context.cmd_params {
|
||||||
|
@ -141,7 +141,7 @@ $vdoctor_output
|
|||||||
|
|
||||||
**What did you do?**
|
**What did you do?**
|
||||||
`v -g -o vdbg cmd/v && vdbg $file_path`
|
`v -g -o vdbg cmd/v && vdbg $file_path`
|
||||||
{file_content}
|
\{file_content}
|
||||||
|
|
||||||
**What did you expect to see?**
|
**What did you expect to see?**
|
||||||
|
|
||||||
@ -150,11 +150,11 @@ $expected_result
|
|||||||
**What did you see instead?**
|
**What did you see instead?**
|
||||||
```
|
```
|
||||||
$build_output```'
|
$build_output```'
|
||||||
mut encoded_body := urllib.query_escape(raw_body.replace_once('{file_content}', '```v\n$file_content\n```'))
|
mut encoded_body := urllib.query_escape(raw_body.replace_once(r'{file_content}', '```v\n$file_content\n```'))
|
||||||
mut generated_uri := 'https://github.com/vlang/v/issues/new?labels=Bug&body=$encoded_body'
|
mut generated_uri := 'https://github.com/vlang/v/issues/new?labels=Bug&body=$encoded_body'
|
||||||
if generated_uri.len > 8192 {
|
if generated_uri.len > 8192 {
|
||||||
// GitHub doesn't support URLs longer than 8192 characters
|
// GitHub doesn't support URLs longer than 8192 characters
|
||||||
encoded_body = urllib.query_escape(raw_body.replace_once('{file_content}', 'See attached file `$file_path`'))
|
encoded_body = urllib.query_escape(raw_body.replace_once(r'{file_content}', 'See attached file `$file_path`'))
|
||||||
generated_uri = 'https://github.com/vlang/v/issues/new?labels=Bug&body=$encoded_body'
|
generated_uri = 'https://github.com/vlang/v/issues/new?labels=Bug&body=$encoded_body'
|
||||||
println('Your file is too big to be submitted. Head over to the following URL and attach your file.')
|
println('Your file is too big to be submitted. Head over to the following URL and attach your file.')
|
||||||
println(generated_uri)
|
println(generated_uri)
|
||||||
|
@ -504,7 +504,7 @@ fn test_struct_print() {
|
|||||||
}
|
}
|
||||||
a.b << b
|
a.b << b
|
||||||
a.b << b
|
a.b << b
|
||||||
assert a.str() == '{Test [{1 2}, {1 2}]}'
|
assert a.str() == r'{Test [{1 2}, {1 2}]}'
|
||||||
assert b.str() == '{1 2}'
|
assert b.str() == '{1 2}'
|
||||||
assert a.b.str() == '[{1 2}, {1 2}]'
|
assert a.b.str() == '[{1 2}, {1 2}]'
|
||||||
}
|
}
|
||||||
|
@ -152,9 +152,9 @@ pub fn gen(files []&ast.File, table &ast.Table, pref &pref.Preferences) string {
|
|||||||
// builtin types
|
// builtin types
|
||||||
if g.file.mod.name == 'builtin' && !g.generated_builtin {
|
if g.file.mod.name == 'builtin' && !g.generated_builtin {
|
||||||
g.gen_builtin_type_defs()
|
g.gen_builtin_type_defs()
|
||||||
g.writeln('Object.defineProperty(array.prototype,"len", { get: function() {return new int(this.arr.arr.length);}, set: function(l) { this.arr.arr.length = l.valueOf(); } }); ')
|
g.writeln('Object.defineProperty(array.prototype,"len", { get: function() { return new int(this.arr.arr.length);}, set: function(l) { this.arr.arr.length = l.valueOf(); } }); ')
|
||||||
g.writeln('Object.defineProperty(map.prototype,"len", { get: function() {return new int(this.length);}, set: function(l) { } }); ')
|
g.writeln('Object.defineProperty(map.prototype,"len", { get: function() { return new int(this.length);}, set: function(l) { } }); ')
|
||||||
g.writeln('Object.defineProperty(array.prototype,"length", { get: function() {return new int(this.arr.arr.length);}, set: function(l) { this.arr.arr.length = l.valueOf(); } }); ')
|
g.writeln('Object.defineProperty(array.prototype,"length", { get: function() { return new int(this.arr.arr.length);}, set: function(l) { this.arr.arr.length = l.valueOf(); } }); ')
|
||||||
g.generated_builtin = true
|
g.generated_builtin = true
|
||||||
}
|
}
|
||||||
if g.is_test && !tests_inited {
|
if g.is_test && !tests_inited {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user