mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
v2: more informative assert output; string interpolation formatting
This commit is contained in:
25
vlib/compiler/tests/string_struct_interpolation_test.v
Normal file
25
vlib/compiler/tests/string_struct_interpolation_test.v
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
struct Foo {
|
||||
bar int
|
||||
mut:
|
||||
str string
|
||||
}
|
||||
|
||||
fn (f Foo) baz() string {
|
||||
return 'baz'
|
||||
}
|
||||
|
||||
fn test_string_method_interpolation() {
|
||||
foo := Foo{}
|
||||
s := 'baz=${foo.baz()}'
|
||||
assert s == 'baz=baz'
|
||||
}
|
||||
|
||||
fn test_adding_to_mutable_string_field() {
|
||||
mut foo := Foo{10, 'hi'}
|
||||
assert foo.bar == 10
|
||||
assert foo.str == 'hi'
|
||||
foo.str += '!'
|
||||
eprintln( foo.str )
|
||||
assert foo.str == 'hi!'
|
||||
}
|
Reference in New Issue
Block a user