emit: converto to Boolean in Bool()

This commit is contained in:
Evgenii Stratonikov 2020-04-28 17:36:58 +03:00
parent 2fd63387c0
commit 4b064e18aa
3 changed files with 3 additions and 2 deletions

View file

@ -46,7 +46,7 @@ func TestConvert(t *testing.T) {
{"int64", "[]byte{0, 1, 0}", big.NewInt(256)},
{"int64", "[]byte{0}", big.NewInt(0)},
{"[]byte", "true", []byte{1}},
{"[]byte", "false", []byte{}},
{"[]byte", "false", []byte{0}},
{"[]byte", "12", []byte{0x0C}},
{"[]byte", "0", []byte{}},
{"[]byte", "[]byte{0, 1, 0}", []byte{0, 1, 0}},

View file

@ -274,7 +274,7 @@ var structTestCases = []testCase{
vm.NewBigIntegerItem(big.NewInt(1)),
vm.NewBigIntegerItem(big.NewInt(2)),
vm.NewByteArrayItem([]byte("hello")),
vm.NewByteArrayItem([]byte{}),
vm.NewBoolItem(false),
},
},
{

View file

@ -31,6 +31,7 @@ func Bool(w *io.BinWriter, ok bool) {
return
}
Opcode(w, opcode.PUSHF)
Instruction(w, opcode.CONVERT, []byte{0x20}) // 0x20 for Boolean type
}
func padRight(s int, buf []byte) []byte {