mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
println: optimize and remove memory leaks
This commit is contained in:
@ -8,6 +8,7 @@ struct B{
|
||||
mut:
|
||||
a A
|
||||
}
|
||||
|
||||
struct C {
|
||||
mut:
|
||||
b B
|
||||
@ -15,6 +16,11 @@ mut:
|
||||
as []A
|
||||
num int
|
||||
}
|
||||
|
||||
struct User {
|
||||
name string
|
||||
age int
|
||||
}
|
||||
|
||||
fn test_struct_levels() {
|
||||
mut c := C{}
|
||||
@ -42,3 +48,9 @@ fn test_struct_levels() {
|
||||
c.as[0].val = 10
|
||||
assert c.as[0].val == 10
|
||||
}
|
||||
|
||||
fn test_struct_str() {
|
||||
u := User{'Bob', 30}
|
||||
println(u) // make sure the struct is printable
|
||||
// assert u.str() == '{name:"Bob", age:30}' // TODO
|
||||
}
|
||||
|
Reference in New Issue
Block a user