diff options
| author | Mel <einebeere@gmail.com> | 2022-08-31 14:22:28 +0000 |
|---|---|---|
| committer | Mel <einebeere@gmail.com> | 2022-08-31 14:22:28 +0000 |
| commit | aeb63ade341572bb307f23ff7c501c48957cc7d4 (patch) | |
| tree | 93cea2e714a212a4a93cc567951a18e6dff4e2f3 /pkg/lang/vm/vm_test.go | |
| parent | c935cde4c4ec65192d51933202e270da1e4d2050 (diff) | |
| download | jinx-aeb63ade341572bb307f23ff7c501c48957cc7d4.tar.zst jinx-aeb63ade341572bb307f23ff7c501c48957cc7d4.zip | |
Remove temporary array operations
Diffstat (limited to 'pkg/lang/vm/vm_test.go')
| -rw-r--r-- | pkg/lang/vm/vm_test.go | 47 |
1 files changed, 33 insertions, 14 deletions
diff --git a/pkg/lang/vm/vm_test.go b/pkg/lang/vm/vm_test.go index ea4123f..a8b479b 100644 --- a/pkg/lang/vm/vm_test.go +++ b/pkg/lang/vm/vm_test.go @@ -39,16 +39,20 @@ func TestFibonacci(t *testing.T) { push_array get_local 0 + get_member "push" push_int 1 - temp_arr_push + call 1 get_local 0 + get_member "push" push_int 1 - temp_arr_push + call 1 + drop 2 @fib_loop: get_local 0 - temp_arr_len + get_member "length" + call 0 push_int 1 @@ -56,6 +60,8 @@ func TestFibonacci(t *testing.T) { sub get_local 0 + get_member "push" + get_local 0 # This is the last element get_local 1 @@ -73,13 +79,15 @@ func TestFibonacci(t *testing.T) { index add - temp_arr_push + call 1 + drop 1 # Drop local 1, which was the length of the array, which we no longer need drop 1 get_local 0 - temp_arr_len + get_member "length" + call 0 push_int 10 @@ -151,19 +159,23 @@ func TestEscapedEnv(t *testing.T) { push_array get_local 1 + get_member "push" get_local 0 call 0 - temp_arr_push + call 1 get_local 1 + get_member "push" get_local 0 call 0 - temp_arr_push + call 1 get_local 1 + get_member "push" get_local 0 call 0 - temp_arr_push + call 1 + drop 3 halt @create: @@ -229,16 +241,20 @@ func TestMember(t *testing.T) { push_array get_local 0 + get_member "push" push_int 1 - temp_arr_push + call 1 get_local 0 + get_member "push" push_int 2 - temp_arr_push + call 1 get_local 0 + get_member "push" push_int 3 - temp_arr_push + call 1 + drop 3 get_member "length" call 0 @@ -393,7 +409,6 @@ func TestPrimes(t *testing.T) { lte jf @prime_check - get_local 0 get_local 3 mod @@ -404,8 +419,10 @@ func TestPrimes(t *testing.T) { jf @factor_loop_inc get_local 2 + get_member "push" get_local 3 - temp_arr_push + call 1 + drop 1 @factor_loop_inc: get_local 3 @@ -424,8 +441,10 @@ func TestPrimes(t *testing.T) { jf @main_loop_inc get_local 1 + get_member "push" get_local 0 - temp_arr_push + call 1 + drop 1 @main_loop_inc: get_local 0 |
