Allow key values to be quoted

This commit is contained in:
Derek Collison
2013-08-07 08:31:48 -07:00
parent 122f06816e
commit b2187a7514
2 changed files with 42 additions and 1 deletions

View File

@@ -246,6 +246,32 @@ func TestNestedMaps(t *testing.T) {
expect(t, lx, expectedItems)
}
func TestQuotedKeys(t *testing.T) {
expectedItems := []item{
{itemKey, "foo", 1},
{itemInteger, "123", 1},
{itemEOF, "", 1},
}
lx := lex("foo : 123")
expect(t, lx, expectedItems)
lx = lex("'foo' : 123")
expect(t, lx, expectedItems)
lx = lex("\"foo\" : 123")
expect(t, lx, expectedItems)
}
func TestQuotedKeysWithSpace(t *testing.T) {
expectedItems := []item{
{itemKey, " foo", 1},
{itemInteger, "123", 1},
{itemEOF, "", 1},
}
lx := lex("' foo' : 123")
expect(t, lx, expectedItems)
lx = lex("\" foo\" : 123")
expect(t, lx, expectedItems)
}
func TestColonKeySep(t *testing.T) {
expectedItems := []item{
{itemKey, "foo", 1},