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

Function TestArithmetic

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

Source from the content-addressed store, hash-verified

228}
229
230func TestArithmetic(t *testing.T) {
231
232 checkStackOpCode(t, ADD, []Value{1, 2}, []Value{3})
233 checkStackOpCode(t, SUB, []Value{1, 2}, []Value{-1})
234
235 checkStackOpCode(t, MUL, []Value{3, 2}, []Value{6})
236
237 checkStackOpCode(t, DIV, []Value{3, 2}, []Value{1})
238 checkStackOpCode(t, DIV, []Value{103, 2}, []Value{51})
239
240 checkStackOpCode(t, MOD, []Value{1, 2}, []Value{1})
241 checkStackOpCode(t, MOD, []Value{math.MaxInt64, 2}, []Value{1})
242 checkStackOpCode(t, MOD, []Value{-math.MaxInt64, 2}, []Value{-1})
243
244 checkStackOpCode(t, MAX, []Value{3, 2}, []Value{3})
245 checkStackOpCode(t, MAX, []Value{-3, 2}, []Value{2})
246
247 checkStackOpCode(t, MIN, []Value{3, 2}, []Value{2})
248 checkStackOpCode(t, MIN, []Value{-3, 2}, []Value{-3})
249
250 checkStackOpCode(t, SIGN, []Value{3}, []Value{1})
251 checkStackOpCode(t, SIGN, []Value{-3}, []Value{-1})
252 checkStackOpCode(t, SIGN, []Value{0}, []Value{0})
253
254 checkStackOpCode(t, INC, []Value{-10}, []Value{-9})
255 checkStackOpCode(t, DEC, []Value{-10}, []Value{-11})
256 checkStackOpCode(t, NEGATE, []Value{-10}, []Value{10})
257 checkStackOpCode(t, ABS, []Value{-10}, []Value{10})
258
259 checkStackOpCode(t, NOT, []Value{1}, []Value{false})
260 checkStackOpCode(t, NOT, []Value{0}, []Value{1})
261
262 checkStackOpCode(t, NZ, []Value{0}, []Value{false})
263 checkStackOpCode(t, NZ, []Value{-10}, []Value{true})
264 checkStackOpCode(t, NZ, []Value{10}, []Value{true})
265}
266
267func TestArrayOpCode(t *testing.T) {
268 checkStackOpCode(t, ARRAYSIZE, []Value{"12345"}, []Value{5})

Callers

nothing calls this directly

Calls 1

checkStackOpCodeFunction · 0.85

Tested by

no test coverage detected