Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion common/env/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,15 @@ func (p *typeDescParser) parseTypeParamIdent() (string, error) {
}

func (p *typeDescParser) skipWhitespace() {
for p.pos < p.length && p.text[p.pos] == ' ' {
for p.pos < p.length && isWhitespace(p.text[p.pos]) {
p.pos++
}
}

func isWhitespace(c byte) bool {
return c == ' ' || c == '\t' || c == '\n' || c == '\r'
}

func isAlpha(c byte) bool {
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
}
Expand Down
41 changes: 41 additions & 0 deletions common/env/io_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ func TestParseTypeDesc(t *testing.T) {
"map<int, list<string>>",
NewTypeDesc("map", NewTypeDesc("int"), NewTypeDesc("list", NewTypeDesc("string"))),
},
{
"list<\n\tint\n>",
NewTypeDesc("list", NewTypeDesc("int")),
},
{
"map<\r\n string,\r\n list<string>\r\n>",
NewTypeDesc("map", NewTypeDesc("string"), NewTypeDesc("list", NewTypeDesc("string"))),
},
{
"map<string,\tint>",
NewTypeDesc("map", NewTypeDesc("string"), NewTypeDesc("int")),
},
}
for _, tc := range tcs {
t.Run(tc.text, func(t *testing.T) {
Expand Down Expand Up @@ -235,6 +247,35 @@ functions:
return:
type_name: V
is_type_param: true
`,
},
{
name: "multiline and tab whitespace in types",
yamlIn: `name: user_env
variables:
- name: user_lookup_table
type: >-
map<
string,
list<string>
>
- name: permissions
type: "map<string,\tint>"
`,
yamlOut: `name: user_env
variables:
- name: user_lookup_table
type_name: map
params:
- type_name: string
- type_name: list
params:
- type_name: string
- name: permissions
type_name: map
params:
- type_name: string
- type_name: int
`,
},
}
Expand Down
Loading