From 4241593b42bffac2f8fcb63f1e88621fe025e360 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Mon, 4 Sep 2023 16:58:15 +0200 Subject: codegen: add interpreter tests Also simplify project structure. The executable is now produced in the root directory. Work in progress. --- codegen/compiler_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'codegen/compiler_test.go') diff --git a/codegen/compiler_test.go b/codegen/compiler_test.go index a876d52..fbe8bb2 100644 --- a/codegen/compiler_test.go +++ b/codegen/compiler_test.go @@ -12,7 +12,7 @@ import ( func TestCodeGen(t *testing.T) { log.SetFlags(log.Lshortfile) - for _, test := range tests { + for _, test := range codeGenTests { test := test t.Run("", func(t *testing.T) { c := NewCompiler() @@ -32,13 +32,13 @@ func TestCodeGen(t *testing.T) { t.Log("data:", c.Data) t.Log("code:", vm1.Disassemble(c.Code)) if s := vm1.Disassemble(c.Code); s != test.asm { - t.Errorf("got error %#v, want error %#v", s, test.asm) + t.Errorf("got %#v, want %#v", s, test.asm) } }) } } -var tests = []struct { +var codeGenTests = []struct { src, asm, sym, err string }{{ // #00 src: "1+2", @@ -55,4 +55,4 @@ var tests = []struct { }, { // #04 src: "func add(a int, b int) int { return a + b }", asm: "Fdup -2\nFdup -3\nAdd\nReturn 1 2\n", -}, {}} +}} -- cgit v1.2.3