1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

wrap up struct default vals + tests

This commit is contained in:
Alexander Medvednikov
2019-11-24 15:56:14 +03:00
parent 268a6dc6d9
commit a4ab7b14c1
3 changed files with 35 additions and 3 deletions

View File

@@ -118,3 +118,19 @@ fn test_mutable_fields() {
u.name = 'Peter'
assert u.name == 'Peter'
}
struct Def {
a int
b int = 7
}
fn test_default_vals() {
d := Def{}
assert d.a == 0
assert d.b == 7
d2 := Def{10, 20}
assert d2.a == 10
assert d2.b == 20
}