This commit is contained in:
Alexander Wang 2024-11-21 19:45:59 -08:00
parent a27f46b98d
commit 271662b546
No known key found for this signature in database
GPG key ID: D89FA31966BDBECE

View file

@ -1723,6 +1723,50 @@ y
}
},
},
{
name: "reserved_quoted/1",
text: `x: {
"label": hello
}
`,
assertions: func(t *testing.T, g *d2graph.Graph) {
assert.Equal(t, 2, len(g.Objects))
},
},
{
name: "reserved_quoted/2",
text: `my_table: {
shape: sql_table
width: 200
height: 200
"shape": string
"icon": string
"width": int
"height": int
}
`,
assertions: func(t *testing.T, g *d2graph.Graph) {
assert.Equal(t, 4, len(g.Objects[0].SQLTable.Columns))
assert.Equal(t, `"shape"`, g.Objects[0].SQLTable.Columns[0].Name.Label)
},
},
{
name: "reserved_quoted/3",
text: `*."shape"
x
`,
assertions: func(t *testing.T, g *d2graph.Graph) {
assert.Equal(t, 2, len(g.Objects))
assert.Equal(t, `x.'"shape"'`, g.Objects[0].AbsID())
},
},
{
name: "reserved_quoted/4",
text: `x."style"."fill"`,
assertions: func(t *testing.T, g *d2graph.Graph) {
assert.Equal(t, 3, len(g.Objects))
},
},
{
name: "errors/reserved_icon_style",