mirror of https://github.com/goccy/go-json.git
parent
28eaf919d5
commit
0065357ebb
|
@ -2148,3 +2148,23 @@ func TestEmptyStructInterface(t *testing.T) {
|
||||||
t.Fatalf("failed to encode empty struct interface. expected:[%q] but got:[%q]", expected, got)
|
t.Fatalf("failed to encode empty struct interface. expected:[%q] but got:[%q]", expected, got)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestIssue290(t *testing.T) {
|
||||||
|
type Issue290 interface {
|
||||||
|
A()
|
||||||
|
}
|
||||||
|
var a struct {
|
||||||
|
A Issue290
|
||||||
|
}
|
||||||
|
expected, err := stdjson.Marshal(a)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
got, err := json.Marshal(a)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if !bytes.Equal(expected, got) {
|
||||||
|
t.Fatalf("failed to encode non empty interface. expected = %q but got %q", expected, got)
|
||||||
|
}
|
||||||
|
}
|
|
@ -194,7 +194,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
|
||||||
if code.Flags&encoder.NonEmptyInterfaceFlags != 0 {
|
if code.Flags&encoder.NonEmptyInterfaceFlags != 0 {
|
||||||
iface := (*nonEmptyInterface)(up)
|
iface := (*nonEmptyInterface)(up)
|
||||||
ifacePtr = iface.ptr
|
ifacePtr = iface.ptr
|
||||||
|
if iface.itab != nil {
|
||||||
typ = iface.itab.typ
|
typ = iface.itab.typ
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
iface := (*emptyInterface)(up)
|
iface := (*emptyInterface)(up)
|
||||||
ifacePtr = iface.ptr
|
ifacePtr = iface.ptr
|
||||||
|
|
|
@ -194,7 +194,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
|
||||||
if code.Flags&encoder.NonEmptyInterfaceFlags != 0 {
|
if code.Flags&encoder.NonEmptyInterfaceFlags != 0 {
|
||||||
iface := (*nonEmptyInterface)(up)
|
iface := (*nonEmptyInterface)(up)
|
||||||
ifacePtr = iface.ptr
|
ifacePtr = iface.ptr
|
||||||
|
if iface.itab != nil {
|
||||||
typ = iface.itab.typ
|
typ = iface.itab.typ
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
iface := (*emptyInterface)(up)
|
iface := (*emptyInterface)(up)
|
||||||
ifacePtr = iface.ptr
|
ifacePtr = iface.ptr
|
||||||
|
|
|
@ -194,7 +194,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
|
||||||
if code.Flags&encoder.NonEmptyInterfaceFlags != 0 {
|
if code.Flags&encoder.NonEmptyInterfaceFlags != 0 {
|
||||||
iface := (*nonEmptyInterface)(up)
|
iface := (*nonEmptyInterface)(up)
|
||||||
ifacePtr = iface.ptr
|
ifacePtr = iface.ptr
|
||||||
|
if iface.itab != nil {
|
||||||
typ = iface.itab.typ
|
typ = iface.itab.typ
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
iface := (*emptyInterface)(up)
|
iface := (*emptyInterface)(up)
|
||||||
ifacePtr = iface.ptr
|
ifacePtr = iface.ptr
|
||||||
|
|
|
@ -194,7 +194,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
|
||||||
if code.Flags&encoder.NonEmptyInterfaceFlags != 0 {
|
if code.Flags&encoder.NonEmptyInterfaceFlags != 0 {
|
||||||
iface := (*nonEmptyInterface)(up)
|
iface := (*nonEmptyInterface)(up)
|
||||||
ifacePtr = iface.ptr
|
ifacePtr = iface.ptr
|
||||||
|
if iface.itab != nil {
|
||||||
typ = iface.itab.typ
|
typ = iface.itab.typ
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
iface := (*emptyInterface)(up)
|
iface := (*emptyInterface)(up)
|
||||||
ifacePtr = iface.ptr
|
ifacePtr = iface.ptr
|
||||||
|
|
|
@ -194,7 +194,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
|
||||||
if code.Flags&encoder.NonEmptyInterfaceFlags != 0 {
|
if code.Flags&encoder.NonEmptyInterfaceFlags != 0 {
|
||||||
iface := (*nonEmptyInterface)(up)
|
iface := (*nonEmptyInterface)(up)
|
||||||
ifacePtr = iface.ptr
|
ifacePtr = iface.ptr
|
||||||
|
if iface.itab != nil {
|
||||||
typ = iface.itab.typ
|
typ = iface.itab.typ
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
iface := (*emptyInterface)(up)
|
iface := (*emptyInterface)(up)
|
||||||
ifacePtr = iface.ptr
|
ifacePtr = iface.ptr
|
||||||
|
|
Loading…
Reference in New Issue