2024-05-26 06:19:08 +02:00
|
|
|
// Copyright (c) 2024 Celestino Amoroso (celestino.amoroso@gmail.com).
|
|
|
|
// All rights reserved.
|
|
|
|
|
2024-05-28 07:26:05 +02:00
|
|
|
// t_index_test.go
|
2024-05-26 06:19:08 +02:00
|
|
|
package expr
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestCollections(t *testing.T) {
|
|
|
|
section := "Collection"
|
|
|
|
inputs := []inputType{
|
|
|
|
/* 1 */ {`"abcdef"[1:3]`, "bc", nil},
|
|
|
|
/* 2 */ {`"abcdef"[:3]`, "abc", nil},
|
|
|
|
/* 3 */ {`"abcdef"[1:]`, "bcdef", nil},
|
|
|
|
/* 4 */ {`"abcdef"[:]`, "abcdef", nil},
|
|
|
|
// /* 5 */ {`[0,1,2,3,4][:]`, ListType{int64(0), int64(1), int64(2), int64(3), int64(4)}, nil},
|
2024-05-26 06:30:42 +02:00
|
|
|
/* 5 */ {`"abcdef"[1:2:3]`, nil, errors.New(`[1:14] left operand '(1, 2)' [pair] and right operand '3' [integer] are not compatible with operator ":"`)},
|
2024-05-26 06:19:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
t.Setenv("EXPR_PATH", ".")
|
|
|
|
|
|
|
|
// parserTestSpec(t, section, inputs, 5)
|
2024-06-25 10:59:03 +02:00
|
|
|
runTestSuite(t, section, inputs)
|
2024-05-26 06:19:08 +02:00
|
|
|
}
|