fix wasm and tests
All checks were successful
/ test (push) Successful in 51s

This commit is contained in:
Neemek 2026-07-15 21:46:14 +02:00
parent 575fd8e37a
commit 7879184d56
Signed by: neemek
GPG key ID: 84FFE4D7D40AB25E
4 changed files with 40 additions and 59 deletions

View file

@ -14,11 +14,9 @@ type AllTestCase struct {
func GetAllTestCases() map[string]AllTestCase {
return map[string]AllTestCase{
"constant_number": {
"a := 1",
"a := 1\na",
[]Value{&IntegerValue{new(big.Int).SetInt64(1)}},
[]map[string]Value{
{"a": &IntegerValue{new(big.Int).SetInt64(1)}},
},
[]map[string]Value{},
},
"func": {
"fn sum(a: int, b: int) -> int {\n\treturn a + b\n}\nres := sum(1, 2)",
@ -26,50 +24,36 @@ func GetAllTestCases() map[string]AllTestCase {
[]map[string]Value{},
},
"list": {
"a := [1.0, 2.0]\n{}",
[]Value{&NilValue{}},
[]map[string]Value{
{"a": &ListValue{
[]Value{
&FloatValue{1},
&FloatValue{2},
},
}},
},
"a := [1.0, 2.0]\na",
[]Value{&ListValue{
[]Value{
&FloatValue{1},
&FloatValue{2},
},
}},
[]map[string]Value{},
},
"constant_list_concat": {
"a := [1, 2] + [3]\n{}",
[]Value{&NilValue{}},
[]map[string]Value{
{"a": &ListValue{
[]Value{
&IntegerValue{big.NewInt(1)},
&IntegerValue{big.NewInt(2)},
&IntegerValue{big.NewInt(3)},
},
}},
},
"a := [1, 2] + [3]\na",
[]Value{&ListValue{
[]Value{
&IntegerValue{big.NewInt(1)},
&IntegerValue{big.NewInt(2)},
&IntegerValue{big.NewInt(3)},
},
}},
[]map[string]Value{},
},
"list_concat": {
"a := [1.0, 2.0]\nb := a + [3.0]\nnil",
[]Value{&NilValue{}},
[]map[string]Value{
{
"a": &ListValue{
[]Value{
&FloatValue{1},
&FloatValue{2},
},
},
"b": &ListValue{
[]Value{
&FloatValue{1},
&FloatValue{2},
&FloatValue{3},
},
},
"a := [1.0, 2.0]\na + [3.0]",
[]Value{&ListValue{
[]Value{
&FloatValue{1},
&FloatValue{2},
&FloatValue{3},
},
},
}},
[]map[string]Value{},
},
}
}
@ -104,7 +88,7 @@ func TestAll(t *testing.T) {
c := NewCompiler([]rune(tc.src))
t.Log("Compiling parse tree")
err = c.Compile(tree)
_, err = c.Compile(tree)
if err != nil {
t.Fatalf("Compiler had an error: %s", err)
}
@ -143,7 +127,7 @@ func BenchmarkAll(b *testing.B) {
tree, _ := p.Parse(tc.src)
c := NewCompiler([]rune(tc.src))
_ = c.Compile(tree)
_, _ = c.Compile(tree)
vm := NewVM(c.Chunk, 256, 256)