package test import "testing" func TestNop(t *testing.T) { state := assembleAndExecute(t, ` functions: - - [nop] `) expectGlobalMemory(t, state, 0, 0) } func TestCal(t *testing.T) { state := assembleAndExecute(t, ` functions: - - [cal, +1] - [add, g0, 1] - - [mov, g0, 5] `) expectGlobalMemory(t, state, 0, 6) } func TestRet(t *testing.T) { state := assembleAndExecute(t, ` functions: - - [cal, +1] - [add, g0, 1] - [ret] - - [mov, g0, 5] - [ret] - [add, g0, 2] `) expectGlobalMemory(t, state, 0, 6) } func TestMov(t *testing.T) { state := assembleAndExecute(t, ` functions: - - [mov, g0, 1] - [mov, g1, g0] - [mov, f0, 5] - [mov, g2, f0] `) expectGlobalMemory(t, state, 0, 1) expectGlobalMemory(t, state, 1, 1) expectGlobalMemory(t, state, 2, 5) } func TestAdd(t *testing.T) { state := assembleAndExecute(t, ` functions: - - [add, g0, 5] - [add, g0, 2] - [add, g0, g0] - [add, f0, 3] - [add, f0, -2] - [add, g0, f0] `) expectGlobalMemory(t, state, 0, 15) }