vm: stringify InteropInterface stackitem type as InteropInterface

This commit is contained in:
Anna Shaleva 2022-05-25 13:20:21 +03:00
parent 84629b0760
commit a3285eae04
5 changed files with 7 additions and 7 deletions

View file

@ -910,7 +910,7 @@ func (i *Interop) Value() interface{} {
// String implements stringer interface.
func (i *Interop) String() string {
return "Interop"
return "InteropInterface"
}
// Dup implements the Item interface.

View file

@ -126,7 +126,7 @@ var stringerTestCases = []struct {
},
{
input: NewInterop(nil),
result: "Interop",
result: "InteropInterface",
},
{
input: NewPointer(0, nil),

View file

@ -299,7 +299,7 @@ func toJSONWithTypes(data []byte, item Item, seen map[Item]sliceNoPointer) ([]by
case Null:
val = `{"type":"Any"}`
case *Interop:
val = `{"type":"Interop"}`
val = `{"type":"InteropInterface"}`
default:
val = `{"type":"` + item.Type().String() + `","value":`
hasValue = true

View file

@ -235,7 +235,7 @@ func TestToJSONWithTypes(t *testing.T) {
`{"type":"Map","value":[{"key":{"type":"Integer","value":"42"},` +
`"value":{"type":"Boolean","value":false}}]}`},
{"Interop", NewInterop(nil),
`{"type":"Interop"}`},
`{"type":"InteropInterface"}`},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
@ -385,7 +385,7 @@ func TestFromJSONWithTypes(t *testing.T) {
item Item
}{
{"Pointer", `{"type":"Pointer","value":3}`, NewPointer(3, nil)},
{"Interop", `{"type":"Interop"}`, NewInterop(nil)},
{"Interop", `{"type":"InteropInterface"}`, NewInterop(nil)},
{"Null", `{"type":"Any"}`, Null{}},
{"Array", `{"type":"Array","value":[{"type":"Any"}]}`, NewArray([]Item{Null{}})},
}

View file

@ -45,7 +45,7 @@ func (t Type) String() string {
case MapT:
return "Map"
case InteropT:
return "Interop"
return "InteropInterface"
default:
return "INVALID"
}
@ -82,7 +82,7 @@ func FromString(s string) (Type, error) {
return StructT, nil
case "Map":
return MapT, nil
case "Interop":
case "InteropInterface":
return InteropT, nil
default:
return 0xFF, ErrInvalidType