This commit is contained in:
Alexander Wang 2025-02-27 08:45:44 -07:00
parent 024a99bf2b
commit 28cc8d4089
No known key found for this signature in database
GPG key ID: BE3937D0D52D8927
2 changed files with 487 additions and 0 deletions

View file

@ -5450,6 +5450,18 @@ a -> b: {
assert.Equal(t, "This is a->b", g.Edges[0].LegendLabel.Value)
},
},
{
name: "merge-glob-values",
run: func(t *testing.T) {
assertCompile(t, `
"a"
*.style.stroke-width: 2
*.style.font-size: 14
a.width: 339
`, ``)
},
},
}
for _, tc := range tca {

View file

@ -0,0 +1,475 @@
{
"graph": {
"name": "",
"isFolderOnly": false,
"ast": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/merge-glob-values.d2,0:0:0-7:0:78",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/merge-glob-values.d2,1:0:1-1:6:7",
"edges": [
{
"range": "d2/testdata/d2compiler/TestCompile2/globs/merge-glob-values.d2,1:0:1-1:6:7",
"src": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/merge-glob-values.d2,1:0:1-1:1:2",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/merge-glob-values.d2,1:0:1-1:1:2",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
}
]
},
"src_arrow": "",
"dst": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/merge-glob-values.d2,1:5:6-1:6:7",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/merge-glob-values.d2,1:5:6-1:6:7",
"value": [
{
"string": "a",
"raw_string": "a"
}
]
}
}
]
},
"dst_arrow": ">"
}
],
"primary": {},
"value": {}
}
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/merge-glob-values.d2,2:0:8-2:23:31",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/merge-glob-values.d2,2:0:8-2:20:28",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/merge-glob-values.d2,2:0:8-2:1:9",
"value": [
{
"string": "*",
"raw_string": "*"
}
],
"pattern": [
"*"
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/merge-glob-values.d2,2:2:10-2:7:15",
"value": [
{
"string": "style",
"raw_string": "style"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/merge-glob-values.d2,2:8:16-2:20:28",
"value": [
{
"string": "stroke-width",
"raw_string": "stroke-width"
}
]
}
}
]
},
"primary": {},
"value": {
"number": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/merge-glob-values.d2,2:22:30-2:23:31",
"raw": "2",
"value": "2"
}
}
}
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/merge-glob-values.d2,3:0:32-3:21:53",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/merge-glob-values.d2,3:0:32-3:17:49",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/merge-glob-values.d2,3:0:32-3:1:33",
"value": [
{
"string": "*",
"raw_string": "*"
}
],
"pattern": [
"*"
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/merge-glob-values.d2,3:2:34-3:7:39",
"value": [
{
"string": "style",
"raw_string": "style"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/merge-glob-values.d2,3:8:40-3:17:49",
"value": [
{
"string": "font-size",
"raw_string": "font-size"
}
]
}
}
]
},
"primary": {},
"value": {
"number": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/merge-glob-values.d2,3:19:51-3:21:53",
"raw": "14",
"value": "14"
}
}
}
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/merge-glob-values.d2,5:0:55-5:10:65",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/merge-glob-values.d2,5:0:55-5:5:60",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/merge-glob-values.d2,5:0:55-5:1:56",
"value": [
{
"string": "a",
"raw_string": "a"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/merge-glob-values.d2,5:2:57-5:5:60",
"value": [
{
"string": "top",
"raw_string": "top"
}
]
}
}
]
},
"primary": {},
"value": {
"number": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/merge-glob-values.d2,5:7:62-5:10:65",
"raw": "339",
"value": "339"
}
}
}
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/merge-glob-values.d2,6:0:66-6:11:77",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/merge-glob-values.d2,6:0:66-6:6:72",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/merge-glob-values.d2,6:0:66-6:1:67",
"value": [
{
"string": "a",
"raw_string": "a"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/merge-glob-values.d2,6:2:68-6:6:72",
"value": [
{
"string": "left",
"raw_string": "left"
}
]
}
}
]
},
"primary": {},
"value": {
"number": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/merge-glob-values.d2,6:8:74-6:11:77",
"raw": "339",
"value": "339"
}
}
}
}
]
},
"root": {
"id": "",
"id_val": "",
"attributes": {
"label": {
"value": ""
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null,
"shape": {
"value": ""
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
},
"edges": [
{
"index": 0,
"isCurve": false,
"src_arrow": false,
"dst_arrow": true,
"references": [
{
"map_key_edge_index": 0
}
],
"attributes": {
"label": {
"value": ""
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null,
"shape": {
"value": ""
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
}
],
"objects": [
{
"id": "b",
"id_val": "b",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/merge-glob-values.d2,1:0:1-1:1:2",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/merge-glob-values.d2,1:0:1-1:1:2",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": 0
}
],
"attributes": {
"label": {
"value": "b"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {
"strokeWidth": {
"value": "2"
},
"fontSize": {
"value": "14"
}
},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
},
{
"id": "a",
"id_val": "a",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/merge-glob-values.d2,1:5:6-1:6:7",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/merge-glob-values.d2,1:5:6-1:6:7",
"value": [
{
"string": "a",
"raw_string": "a"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": 0
},
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/merge-glob-values.d2,5:0:55-5:5:60",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/merge-glob-values.d2,5:0:55-5:1:56",
"value": [
{
"string": "a",
"raw_string": "a"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/merge-glob-values.d2,5:2:57-5:5:60",
"value": [
{
"string": "top",
"raw_string": "top"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
},
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/merge-glob-values.d2,6:0:66-6:6:72",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/merge-glob-values.d2,6:0:66-6:1:67",
"value": [
{
"string": "a",
"raw_string": "a"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/merge-glob-values.d2,6:2:68-6:6:72",
"value": [
{
"string": "left",
"raw_string": "left"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
}
],
"attributes": {
"label": {
"value": "a"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {
"strokeWidth": {
"value": "2"
},
"fontSize": {
"value": "14"
}
},
"top": {
"value": "339"
},
"left": {
"value": "339"
},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
}
]
},
"err": null
}