Skip to content

Commit

Permalink
Add string concat test
Browse files Browse the repository at this point in the history
  • Loading branch information
TomWright committed Oct 1, 2024
1 parent 28cd36a commit ff73190
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions execution/execute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@ func TestExecuteSelector_HappyPath(t *testing.T) {
s: `name.first`,
out: model.NewStringValue("Tom"),
}))
t.Run("concat", runTest(testCase{
in: inputMap(),
s: `title + " " + (name.first) + " " + (name.last)`,
out: model.NewStringValue("Mr Tom Wright"),
}))
})

t.Run("object", func(t *testing.T) {
Expand Down
5 changes: 5 additions & 0 deletions selector/parser/parse_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ func parseGroup(p *Parser) (ast.Expr, error) {
break
}

if p.current().IsKind(lexer.Dot) {
p.advance()
continue
}

expr, err := p.parseExpression(bpDefault)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion selector/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (p *Parser) endOfExpressionTokens() []lexer.TokenKind {
case scopeObject:
return []lexer.TokenKind{lexer.CloseCurly, lexer.Equals, lexer.Number, lexer.Symbol, lexer.Comma}
case scopeGroup:
return []lexer.TokenKind{lexer.CloseParen}
return append([]lexer.TokenKind{lexer.CloseParen, lexer.Dot}, leftDenotationTokens...)
default:
return nil
}
Expand Down

0 comments on commit ff73190

Please sign in to comment.