Compare commits

..

No commits in common. "4aa0113c6a47f54ade44013682bcaf6e0a9f6c32" and "cf73b5c98da29cd803db9940250fbff4045be1f1" have entirely different histories.

3 changed files with 5 additions and 26 deletions

View File

@ -57,7 +57,7 @@ func evalDot(ctx ExprContext, self *term) (v any, err error) {
case string: case string:
var index int var index int
if index, err = verifyIndex(ctx, indexTerm, len(unboxedValue)); err == nil { if index, err = verifyIndex(ctx, indexTerm, len(unboxedValue)); err == nil {
v = string(unboxedValue[index]) v = unboxedValue[index]
} }
case map[any]any: case map[any]any:
var ok bool var ok bool

View File

@ -35,10 +35,10 @@ func TestGeneralParser(t *testing.T) {
/* 14 */ {`not true`, false, nil}, /* 14 */ {`not true`, false, nil},
/* 15 */ {`true and false`, false, nil}, /* 15 */ {`true and false`, false, nil},
/* 16 */ {`true or false`, true, nil}, /* 16 */ {`true or false`, true, nil},
/* *17 */ {`"uno" + "due"`, `unodue`, nil}, /* 17 */ {`"uno" + "due"`, `unodue`, nil},
/* *18 */ {`"uno" + 2`, `uno2`, nil}, /* 18 */ {`"uno" + 2`, `uno2`, nil},
/* *19 */ {`"uno" + (2+1)`, `uno3`, nil}, /* 19 */ {`"uno" + (2+1)`, `uno3`, nil},
/* *20 */ {`"uno" * (2+1)`, `unounouno`, nil}, /* 20 */ {`"uno" * (2+1)`, `unounouno`, nil},
/* 21 */ {"1", int64(1), nil}, /* 21 */ {"1", int64(1), nil},
/* 22 */ {"1.5", float64(1.5), nil}, /* 22 */ {"1.5", float64(1.5), nil},
/* 23 */ {"1.5*2", float64(3.0), nil}, /* 23 */ {"1.5*2", float64(3.0), nil},

View File

@ -1,21 +0,0 @@
// Copyright (c) 2024 Celestino Amoroso (celestino.amoroso@gmail.com).
// All rights reserved.
// strings_test.go
package expr
import (
"testing"
)
func TestStringsParser(t *testing.T) {
inputs := []inputType{
/* 1 */ {`"uno" + "due"`, `unodue`, nil},
/* 2 */ {`"uno" + 2`, `uno2`, nil},
/* 3 */ {`"uno" + (2+1)`, `uno3`, nil},
/* 4 */ {`"uno" * (2+1)`, `unounouno`, nil},
/* 5 */ {`"abc".1`, `b`, nil},
/* 5 */ {`#"abc"`, int64(3), nil},
}
parserTest(t, "String", inputs)
}