summaryrefslogtreecommitdiff
path: root/interp/interpreter_test.go
diff options
context:
space:
mode:
authorMarc Vertes <mvertes@free.fr>2026-01-13 11:38:22 +0100
committerMarc Vertes <mvertes@free.fr>2026-01-13 11:38:22 +0100
commitde3baf0e06862f0420950f025b3328068f3b6df2 (patch)
tree10dbb5cce38f48b902329af2b721617c8d5966a3 /interp/interpreter_test.go
parent5a04b5512a128bd1805792cca4eabacf5fd49b27 (diff)
fix: improve literal composite on nested types
Diffstat (limited to 'interp/interpreter_test.go')
-rw-r--r--interp/interpreter_test.go25
1 files changed, 15 insertions, 10 deletions
diff --git a/interp/interpreter_test.go b/interp/interpreter_test.go
index 0be2409..0cb4160 100644
--- a/interp/interpreter_test.go
+++ b/interp/interpreter_test.go
@@ -274,15 +274,20 @@ func TestImport(t *testing.T) {
func TestComposite(t *testing.T) {
run(t, []etest{
- {src: "type T struct{}; t := T{}; t", res: "{}"}, // #00
- {src: "t := struct{}{}; t", res: "{}"}, // #01
- {src: `type T struct {}; var t T; t = T{}; t`, res: "{}"}, // #02
- {src: `type T struct{N int; S string}; var t T; t = T{2, "foo"}; t`, res: `{2 foo}`}, // #03
- {src: `type T struct{N int; S string}; t := T{2, "foo"}; t`, res: `{2 foo}`}, // #04
- {src: `type T struct{N int; S string}; t := T{S: "foo"}; t`, res: `{0 foo}`}, // #05
- {src: `a := []int{}`, res: `[]`}, // #06
- {src: `a := []int{1, 2, 3}; a`, res: `[1 2 3]`}, // #07
- {src: `m := map[string]bool{}`, res: `map[]`}, // #08
- {src: `m := map[string]bool{"hello": true}; m`, res: `map[hello:true]`}, // #09
+ {src: "type T struct{}; t := T{}; t", res: "{}"}, // #00
+ {src: "t := struct{}{}; t", res: "{}"}, // #01
+ {src: `type T struct {}; var t T; t = T{}; t`, res: "{}"}, // #02
+ {src: `type T struct{N int; S string}; var t T; t = T{2, "foo"}; t`, res: `{2 foo}`}, // #03
+ {src: `type T struct{N int; S string}; t := T{2, "foo"}; t`, res: `{2 foo}`}, // #04
+ {src: `type T struct{N int; S string}; t := T{S: "foo"}; t`, res: `{0 foo}`}, // #05
+ {src: `a := []int{}`, res: `[]`}, // #06
+ {src: `a := []int{1, 2, 3}; a`, res: `[1 2 3]`}, // #07
+ {src: `m := map[string]bool{}`, res: `map[]`}, // #08
+ {src: `m := map[string]bool{"hello": true}; m`, res: `map[hello:true]`}, // #09
+ {src: `m := map[int]struct{b bool}{1:struct {b bool}{true}}; m`, res: `map[1:{true}]`}, // #10
+ {src: `type T struct {b bool}; m := []T{T{true}}; m`, res: `[{true}]`}, // #11
+ {src: `type T struct {b bool}; m := []T{{true}}; m`, res: `[{true}]`}, // #12
+ {src: `m := []struct{b bool}{{true}}; m`, res: `[{true}]`}, // #13
+ {src: `m := map[int]struct{b bool}{1:{true}}; m`, res: `map[1:{true}]`}, // #14
})
}