Skip to content

Commit

Permalink
Merge pull request #13 from wmak/master
Browse files Browse the repository at this point in the history
fix: Allow conditions containing "-"
  • Loading branch information
zhouzhuojie authored Aug 21, 2020
2 parents ab0d399 + 0542d28 commit d618438
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,11 @@ func (p *Parser) scanArg() (rune, string, error) {
continue
}
t, _ := p.scan()
// Allow variables to contain "-"
if t == '-' {
sep = "-"
continue
}
if t == '}' {
ti, _ := p.scan()
if ti == '{' {
Expand Down
2 changes: 2 additions & 0 deletions parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ var validTestData = []struct {
{"56.43", nil, false, true},
{"{var5}", nil, false, true},
{"{var0} > -100 AND {var0} < -50", map[string]interface{}{"var0": -75.4}, true, false},
{"{var5-type-2}", nil, false, true},
{"{var5-type-2} == 1", map[string]interface{}{"var5-type-2": 1}, true, false},
{"{var0}", map[string]interface{}{"var0": true}, true, false},
{"{var0}", map[string]interface{}{"var0": false}, false, false},
{"\"OFF\"", nil, false, true},
Expand Down

0 comments on commit d618438

Please sign in to comment.