v2 / vlib / v / fmt / tests / string_interpolation_keep.vv
23 lines · 22 sloc · 593 bytes · b45c39f2050cc2f98213ff7c4586aecad2443605
Raw
1import os
2
3fn main() {
4 println('Hello world, args: ${os.args}')
5 i := 123
6 a := 'abc'
7 b := 'xyz'
8 width := 8
9 precision := 3
10 e := 'a: ${a} b: ${b} i: ${i}'
11 d := 'a: ${a:5s} b: ${b:-5s} i: ${i:20d}'
12 g := '${a:(width)} ${i:0(width)d} ${f64(i):(width).(precision)f}'
13 f := 'a byte string'.bytes()
14 println('a: ${a} ${b} xxx')
15 eprintln('e: ${e}')
16 eprintln('g: ${g}')
17 _ = ' ${foo.method(bar).str()} '
18 println('(${some_struct.@type}, ${some_struct.y})')
19 _ := 'CastExpr ${int(d.e).str()}'
20 println('${f[0..4].bytestr()}')
21 _ := '${generic_fn[int]()}'
22 _ := '${foo.generic_method[int]()}'
23}
24