all: add r and R switches for repeating in string interpolation, '${"abc":3r}' == 'abcabcabc' (#20197)

This commit is contained in:
penguindark 2023-12-17 11:23:17 +01:00 committed by GitHub
parent 51aaf3c49f
commit ae16878272
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 47 additions and 3 deletions

View file

@ -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'
}