Added overloaded support for array * int
Some checks failed
Build / build (push) Successful in 10m20s
Test / build (push) Has been cancelled

This commit is contained in:
Chuck Smith
2024-03-24 11:47:31 -04:00
parent 803d717379
commit c9d96236dd
4 changed files with 68 additions and 0 deletions

View File

@@ -481,6 +481,25 @@ func TestArrayLiterals(t *testing.T) {
testIntegerObject(t, result.Elements[2], 6)
}
func TestArrayDuplication(t *testing.T) {
input := "[1] * 3"
evaluated := testEval(input)
result, ok := evaluated.(*object.Array)
if !ok {
t.Fatalf("object is not Array. got=%T (%+v)", evaluated, evaluated)
}
if len(result.Elements) != 3 {
t.Fatalf("array has wrong num of elements. got=%d",
len(result.Elements))
}
testIntegerObject(t, result.Elements[0], 1)
testIntegerObject(t, result.Elements[1], 1)
testIntegerObject(t, result.Elements[2], 1)
}
func TestArrayIndexExpressions(t *testing.T) {
tests := []struct {
input string