mirror of
https://github.com/hanzoai/expr.git
synced 2026-09-24 16:58:58 +00:00
Fix string literal slicing error (#543)
This commit is contained in:
@@ -1180,6 +1180,10 @@ func TestExpr(t *testing.T) {
|
||||
`bitushr(-100, 5)`,
|
||||
576460752303423484,
|
||||
},
|
||||
{
|
||||
`"hello"[1:3]`,
|
||||
"el",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
||||
+1
-2
@@ -369,9 +369,8 @@ func (p *parser) parseSecondary() Node {
|
||||
return node
|
||||
case String:
|
||||
p.next()
|
||||
node := &StringNode{Value: token.Value}
|
||||
node = &StringNode{Value: token.Value}
|
||||
node.SetLocation(token.Location)
|
||||
return node
|
||||
|
||||
default:
|
||||
if token.Is(Bracket, "[") {
|
||||
|
||||
@@ -523,6 +523,14 @@ world`},
|
||||
Property: &IntegerNode{Value: 0},
|
||||
},
|
||||
},
|
||||
{
|
||||
`"hello"[1:3]`,
|
||||
&SliceNode{
|
||||
Node: &StringNode{Value: "hello"},
|
||||
From: &IntegerNode{Value: 1},
|
||||
To: &IntegerNode{Value: 3},
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
t.Run(test.input, func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user