MCPcopy Create free account
hub / github.com/DNAProject/DNA / TestStackOpCode

Function TestStackOpCode

vm/neovm/stack_opcode_test.go:181–228  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

179}
180
181func TestStackOpCode(t *testing.T) {
182 checkStackOpCode(t, SWAP, []Value{1, 2}, []Value{2, 1})
183 checkStackOpCode(t, XDROP, []Value{3, 2, 1}, []Value{2})
184 checkStackOpCode(t, XDROP, []Value{3, 2, 0}, []Value{3})
185 checkStackOpCode(t, XSWAP, []Value{3, 2, 1}, []Value{2, 3})
186 checkStackOpCode(t, XTUCK, []Value{3, 2, 1}, []Value{3, 2, 2})
187 checkStackOpCode(t, DEPTH, []Value{1, 2}, []Value{1, 2, 2})
188 checkStackOpCode(t, DROP, []Value{1, 2}, []Value{1})
189 checkStackOpCode(t, DUP, []Value{1, 2}, []Value{1, 2, 2})
190 checkStackOpCode(t, NIP, []Value{1, 2}, []Value{2})
191 checkStackOpCode(t, OVER, []Value{1, 2}, []Value{1, 2, 1})
192 checkStackOpCode(t, PICK, []Value{3, 2, 1}, []Value{3, 2, 3})
193 checkStackOpCode(t, ROLL, []Value{3, 2, 1}, []Value{2, 3})
194 checkStackOpCode(t, ROT, []Value{4, 3, 2, 1}, []Value{4, 2, 1, 3})
195 checkStackOpCode(t, ROT, []Value{1, 2, 3}, []Value{2, 3, 1})
196 checkStackOpCode(t, TUCK, []Value{1, 2}, []Value{2, 1, 2})
197
198 checkStackOpCode(t, INVERT, []Value{2}, []Value{-3})
199 checkStackOpCode(t, AND, []Value{1, 2}, []Value{0})
200 checkStackOpCode(t, OR, []Value{1, 2}, []Value{3})
201 checkStackOpCode(t, XOR, []Value{1, 2}, []Value{3})
202 checkStackOpCode(t, EQUAL, []Value{1, 2}, []Value{false})
203
204 checkStackOpCode(t, INC, []Value{1}, []Value{2})
205 checkStackOpCode(t, DEC, []Value{2}, []Value{1})
206 checkStackOpCode(t, SIGN, []Value{1}, []Value{1})
207 checkStackOpCode(t, NEGATE, []Value{1}, []Value{-1})
208 checkStackOpCode(t, ABS, []Value{-9999}, []Value{9999})
209 checkStackOpCode(t, ABS, []Value{9999}, []Value{9999})
210 a, _ := new(big.Int).SetString("-83786976294838206464", 10)
211 checkStackOpCode(t, ABS, []Value{a}, []Value{new(big.Int).Abs(a)})
212 checkStackOpCode(t, NOT, []Value{true}, []Value{false})
213
214 b, _ := new(big.Int).SetString("73786976294838206464", 10)
215 checkStackOpCode(t, SHL, []Value{1, new(big.Int).SetUint64(uint64(20))}, []Value{1 << 20})
216 checkStackOpCode(t, SHR, []Value{4, 1}, []Value{2})
217 checkStackOpCode(t, SHR, []Value{b, 10}, []Value{2 << 55})
218 checkStackOpCode(t, BOOLAND, []Value{1, 2}, []Value{1})
219 checkStackOpCode(t, BOOLOR, []Value{1, 2}, []Value{1})
220 checkStackOpCode(t, NUMEQUAL, []Value{1, 2}, []Value{false})
221 checkStackOpCode(t, NUMNOTEQUAL, []Value{1, 2}, []Value{1})
222 checkStackOpCode(t, LT, []Value{1, 2}, []Value{1})
223 checkStackOpCode(t, GT, []Value{1, 2}, []Value{false})
224 checkStackOpCode(t, LTE, []Value{1, 2}, []Value{1})
225 checkStackOpCode(t, GTE, []Value{1, 2}, []Value{false})
226 checkStackOpCode(t, MIN, []Value{1, 2}, []Value{1})
227 checkStackOpCode(t, MAX, []Value{1, 2}, []Value{2})
228}
229
230func TestArithmetic(t *testing.T) {
231

Callers

nothing calls this directly

Calls 2

checkStackOpCodeFunction · 0.85
AbsMethod · 0.80

Tested by

no test coverage detected