Added overloaded support for array * int
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user