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

add (commented-out) problematic multiple-nested struct test-case

This commit is contained in:
Turiiya 2023-08-10 17:23:32 +02:00
parent 21d98ff904
commit f35f14ebbe

View File

@ -15,6 +15,11 @@ struct Pet {
has_furr bool
title JobTitle
address Address
// *¹ Currently it is only possible to decode a single nested struct generically.
// As soon as we decode another nested struct (e.g. within this struct, like `contact` below)
// or only one nested struct within another struct, it results in wrong values or errors.
// Related issue: https://github.com/vlang/v/issues/18110
// contact Contact
}
struct Address {
@ -22,6 +27,12 @@ struct Address {
city string
}
// *¹
/*
struct Contact {
phone string
}*/
struct Employee {
mut:
name string
@ -45,6 +56,8 @@ struct Arrs {
}
fn test_encode_and_decode() {
// *¹
// p := Pet{'Mr. Scratchy McEvilPaws', ['Freddy', 'Fred', 'Charles'], 8, -1, 0.8, true, .manager, Address{'1428 Elm Street', 'Springwood'}, Contact{'123-456-7890'}}
p := Pet{'Mr. Scratchy McEvilPaws', ['Freddy', 'Fred', 'Charles'], 8, -1, 0.8, true, .manager, Address{'1428 Elm Street', 'Springwood'}}
s := 'name = "Mr. Scratchy McEvilPaws"
nicknames = [
@ -58,6 +71,7 @@ height = 0.8
has_furr = true
title = 2
address = { street = "1428 Elm Street", city = "Springwood" }'
// contact = { phone = "123-456-7890" }' // *¹
assert toml.encode[Pet](p) == s
assert toml.decode[Pet](s)! == p