mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
all: add r
and R
switches for repeating in string interpolation, '${"abc":3r}'
== 'abcabcabc' (#20197)
This commit is contained in:
parent
51aaf3c49f
commit
ae16878272
6 changed files with 47 additions and 3 deletions
|
@ -350,3 +350,17 @@ fn test_interpolate_literal_limits() {
|
|||
assert '10 ${u32(0o377777_77777)}' == '10 4294967295'
|
||||
assert '11 ${i64(-2147483647)}' == '11 -2147483647'
|
||||
}
|
||||
|
||||
fn test_string_repetition() {
|
||||
a := 'pippo'
|
||||
assert '${'pera':r}' == ''
|
||||
assert '${'pera':R}' == ''
|
||||
assert '${'pera':0r}' == ''
|
||||
assert '${'pera':0R}' == ''
|
||||
assert '${'pera':1r}' == 'pera'
|
||||
assert '${'pera':1R}' == 'PERA'
|
||||
assert '${'pera':2r}' == 'perapera'
|
||||
assert '${'pera':2R}' == 'PERAPERA'
|
||||
assert '${a:2r}' == 'pippopippo'
|
||||
assert '${a:2R}' == 'PIPPOPIPPO'
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue