Improve code quality

This commit is contained in:
Neemek 2025-03-16 21:16:12 +01:00
parent 5edad332cd
commit 3f260e7ffd
Signed by: neemek
GPG key ID: 28360A8951CD0E9B
11 changed files with 95 additions and 45 deletions

View file

@ -117,7 +117,7 @@ func GetCompileTestData() map[string]CompileTestData {
},
},
},
"conditional_welse_false": {
"conditional_else_false": {
&BlockNode{
[]Node{
&AssignNode{
@ -164,7 +164,7 @@ func GetCompileTestData() map[string]CompileTestData {
},
},
},
"conditional_welse_true": {
"conditional_else_true": {
&BlockNode{
[]Node{
&AssignNode{
@ -363,7 +363,10 @@ func TestCompile(t *testing.T) {
c := NewCompiler()
t.Log("Compiling node tree")
c.Compile(testCase.tree)
err := c.Compile(testCase.tree)
if err != nil {
t.Fatalf("Compiling failed: %v", err)
}
t.Log("Initializing vm")
vm := NewVM(c.Chunk, 256, 256)
@ -387,7 +390,7 @@ func BenchmarkCompile(b *testing.B) {
b.Run(name, func(b *testing.B) {
for i := 0; i < b.N; i++ {
c := NewCompiler()
c.Compile(testCase.tree)
_ = c.Compile(testCase.tree)
}
})
}
@ -426,16 +429,15 @@ func TestCompiler_CleanStack(t *testing.T) {
}
// clean statements
case BlockNodeType:
case ConditionalNodeType:
case LoopNodeType:
case AssignNodeType:
case FunctionNodeType:
default:
}
t.Run(name, func(t *testing.T) {
c := NewCompiler()
c.Compile(tc.tree)
err := c.Compile(tc.tree)
if err != nil {
t.Fatalf("Compiling failed: %v", err)
}
vm := NewVM(c.Chunk, 256, 256)
for vm.Next() {