8e596d5979
1. moved scan/symbol.go to new package sym and adapted all files that reference Symbol type and its values. 2. new type interval defined by begin, end and step values. 3. replaced operator-range.go with operator-interval.go. 4. replaced range operator begin:end with begin..end..step. 5. new implementation of sub-collection extraction based on new interval literal.
43 lines
1018 B
Go
43 lines
1018 B
Go
// Copyright (c) 2024-2026 Celestino Amoroso (celestino.amoroso@gmail.com).
|
|
// All rights reserved.
|
|
|
|
// t_token_test.go
|
|
package expr
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"git.portale-stac.it/go-pkg/expr/scan"
|
|
"git.portale-stac.it/go-pkg/expr/sym"
|
|
)
|
|
|
|
func TestDevString(t *testing.T) {
|
|
type inputType struct {
|
|
source string
|
|
sym sym.Symbol
|
|
value any
|
|
wantResult string
|
|
}
|
|
|
|
inputs := []inputType{
|
|
/* 1 */ {"100", sym.SymInteger, 100, fmt.Sprintf(`[%d]"100"{100}`, sym.SymInteger)},
|
|
/* 2 */ {"+", sym.SymPlus, nil, fmt.Sprintf(`[%d]"+"{}`, sym.SymPlus)},
|
|
}
|
|
|
|
for i, input := range inputs {
|
|
var tk *scan.Token
|
|
if input.value == nil {
|
|
tk = scan.NewToken(0, 0, input.sym, input.source)
|
|
} else {
|
|
tk = scan.NewValueToken(0, 0, input.sym, input.source, input.value)
|
|
}
|
|
|
|
t.Logf("Test nr %2d: %q --> %q", i+1, input.source, input.wantResult)
|
|
|
|
if s := tk.DevString(); s != input.wantResult {
|
|
t.Errorf("wrong token from symbol '+': expected %q, got %q", input.wantResult, s)
|
|
}
|
|
}
|
|
}
|