gurkankaymak / hocon

go implementation of lightbend's HOCON configuration library https://github.com/lightbend/config
MIT License
79 stars 17 forks source link

Parsing error when property end with a num #45

Closed ltagliamonte-dd closed 1 year ago

ltagliamonte-dd commented 1 year ago

Hello @gurkankaymak , thank you for the lib! I'm having a parsing problem when my property ends with a number. I wrote the following test case that is failing and it shouldn’t:

func TestPropertyEndingWithNum(t *testing.T) {
    t.Run("parse config not ending with a num", func(t *testing.T) {
        str_to_test := `my.property.with_num = ["245678", "453678", "65789", "8970"]`
        parser := newParser(strings.NewReader(str_to_test))
        _, err := parser.parse()
        assertNoError(t, err)
    })

    t.Run("parse config ending with num", func(t *testing.T) {
        str_to_test := `my.property.with_num.100 = ["245678", "453678", "65789", "8970"]`
        parser := newParser(strings.NewReader(str_to_test))
        _, err := parser.parse()
        assertNoError(t, err)
    })
}

the test fails with:

--- FAIL: TestPropertyEndingWithNum (0.00s)
    --- FAIL: TestPropertyEndingWithNum/parse_config_with_num (0.00s)
        ~/github.com/gurkankaymak/hocon/parser_test.go:53: not expected an error, got err: "missing comma! at: 1:21, values should have comma or ASCII newline ('\\n') between them"

as you can see the only difference between the two strings under test, is that the latter ends with .100 if i use the HOCON playground the property gets correctly parsed. I also tested the same property with https://github.com/chimpler/pyhocon and it seems legit