vm: implement ISNULL opcode

This commit is contained in:
Evgenii Stratonikov 2020-03-23 12:26:26 +03:00
parent 3db030bbb6
commit f7f48d0048
3 changed files with 22 additions and 0 deletions

View file

@ -206,6 +206,22 @@ func TestPUSHNULL(t *testing.T) {
require.True(t, v.estack.Pop().Bool())
}
func TestISNULL(t *testing.T) {
t.Run("Integer", func(t *testing.T) {
prog := makeProgram(opcode.PUSH1, opcode.ISNULL)
v := load(prog)
runVM(t, v)
require.False(t, v.estack.Pop().Bool())
})
t.Run("Null", func(t *testing.T) {
prog := makeProgram(opcode.PUSHNULL, opcode.ISNULL)
v := load(prog)
runVM(t, v)
require.True(t, v.estack.Pop().Bool())
})
}
// appendBigStruct returns a program which:
// 1. pushes size Structs on stack
// 2. packs them into a new struct