forked from TrueCloudLab/neoneo-go
vm: compare Map by reference in EQUAL
This commit is contained in:
parent
c0be2b2a99
commit
c66f493017
2 changed files with 26 additions and 0 deletions
|
@ -478,6 +478,11 @@ func (v *VM) execute(ctx *Context, op Instruction) {
|
|||
v.estack.PushVal(ta == tb)
|
||||
break
|
||||
}
|
||||
} else if ma, ok := a.value.(*MapItem); ok {
|
||||
if mb, ok := b.value.(*MapItem); ok {
|
||||
v.estack.PushVal(ma == mb)
|
||||
break
|
||||
}
|
||||
}
|
||||
v.estack.PushVal(reflect.DeepEqual(a, b))
|
||||
|
||||
|
|
|
@ -446,6 +446,27 @@ func TestEQUALArrayFalse(t *testing.T) {
|
|||
assert.Equal(t, &BoolItem{false}, vm.estack.Pop().value)
|
||||
}
|
||||
|
||||
func TestEQUALMapTrue(t *testing.T) {
|
||||
prog := makeProgram(DUP, EQUAL)
|
||||
vm := load(prog)
|
||||
vm.estack.Push(&Element{value: NewMapItem()})
|
||||
vm.Run()
|
||||
assert.Equal(t, false, vm.HasFailed())
|
||||
assert.Equal(t, 1, vm.estack.Len())
|
||||
assert.Equal(t, &BoolItem{true}, vm.estack.Pop().value)
|
||||
}
|
||||
|
||||
func TestEQUALMapFalse(t *testing.T) {
|
||||
prog := makeProgram(EQUAL)
|
||||
vm := load(prog)
|
||||
vm.estack.Push(&Element{value: NewMapItem()})
|
||||
vm.estack.Push(&Element{value: NewMapItem()})
|
||||
vm.Run()
|
||||
assert.Equal(t, false, vm.HasFailed())
|
||||
assert.Equal(t, 1, vm.estack.Len())
|
||||
assert.Equal(t, &BoolItem{false}, vm.estack.Pop().value)
|
||||
}
|
||||
|
||||
func TestNumEqual(t *testing.T) {
|
||||
prog := makeProgram(NUMEQUAL)
|
||||
vm := load(prog)
|
||||
|
|
Loading…
Reference in a new issue